actor n background

Non-platform specific questions.

actor n background

Postby dzuncoi » Tue Jun 05, 2012 11:38 am

hello guys, im just use game editor for 3 days, i want to ask u some questions
i create an actor, it can move by left n right key, but i dunno how to make background follow the actor :(
i try to use wire frame region actor and add collision event to them but still not work, i dunno why :( anyone can help me clearly ?
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby phyzix5761 » Tue Jun 05, 2012 4:12 pm

If you just want a basic follow you have to parent the background to your actor. Go into the actor control menu for the background and change parent to the actor you want the background to follow.
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: actor n background

Postby skydereign » Tue Jun 05, 2012 4:32 pm

phyzix5761 wrote:If you just want a basic follow you have to parent the background to your actor. Go into the actor control menu for the background and change parent to the actor you want the background to follow.

That won't work, due to the child actor always being on a higher zdepth than its parent. Most likely though you want it to just follow the view. Depending on how you are doing view movement (if your view is parented to the player) you need to do this.
background -> Draw Actor -> Script Editor
Code: Select all
xscreen=view.width/2; // this will center the background actor to the view
yscreen=view.height/2;


Or if you aren't parenting the player to the view, you can just parent the background to the view. If though your background appears in front of the player, either raise the player's zdepth, or better yet lower the view's zdepth.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor n background

Postby dzuncoi » Wed Jun 06, 2012 6:02 am

arrrrrrrrr thank u guy, i got it :D just need to parent 2,3 actor, so simple :D
can i ask some more questions :?
anyone help me explain these code plz

Code: Select all
switch(STATE)
{
    case 0:
    break;

    case 1:
    break;
 
    case 2:
    break;
 
    case 3:
    break;
 
    case 4:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
 //       STATE=6;
    }
    break;
 
    case 5:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
 //       STATE=7;
    }
    break;
 
    case 6:
    break;
 
    case 7:
    break;
 
    // turning animation
 
}
if(yvelocity>3)
{
    if(STATE%2==1)
    {
        ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
        STATE=7;
    }
    else
    {
        ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
        STATE=6;
    }
}
yvelocity++;


explain me what it's for n meaning of the commands clearly, thank very much :)
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby happyjustbecause » Wed Jun 06, 2012 6:49 am

dzuncoi wrote:arrrrrrrrr thank u guy, i got it :D just need to parent 2,3 actor, so simple :D
can i ask some more questions :?
anyone help me explain these code plz

Code: Select all
switch(STATE)
{
    case 0:
    break;

    case 1:
    break;
 
    case 2:
    break;
 
    case 3:
    break;
 
    case 4:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
 //       STATE=6;
    }
    break;
 
    case 5:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
 //       STATE=7;
    }
    break;
 
    case 6:
    break;
 
    case 7:
    break;
 
    // turning animation
 
}
if(yvelocity>3)
{
    if(STATE%2==1)
    {
        ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
        STATE=7;
    }
    else
    {
        ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
        STATE=6;
    }
}
yvelocity++;


explain me what it's for n meaning of the commands clearly, thank very much :)


Well, I'll attempt to explain the code for you, as I learned this method. So...

Code: Select all
switch(STATE)


This means that you are switching a variable called STATE. This variable can be used for anything, but in this case it is used for switching animations and preventing moonwalking.

Code: Select all
case 0:
break;

case 1:
break;


These are the conditions for when state is equal to 0 or 1. It is basically saying if state is equal to 0 (or whatever # it may be), run this code until a break. So if you want to set the color value red to 0 when in case 0, and you want to switch to state equaling 1 you would put:

Code: Select all
case 0: // switch r value to 0
r=0;
state=1;
break;


generally case 0 and case 1 are the standing right and left states. So the state method can be used for changing animations in this way:

Code: Select all
case 0: // Right Stand to Right Run
ChangeAnimation("Event Actor", "Right Run", FORWARD);
state=2;
break;

case 1: // Left Stand to Left Run
ChangeAnimation("Event Actor", "Left Run", FORWARD);
state=3;
break;


Code: Select all
    case 4:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
 //       STATE=6;
    }
    break;
 
    case 5:
    if(yvelocity>0)
    {
 //       ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
 //       STATE=7;
    }
    break;


cases 4 and 5 would be the falling animations switching. And the animations and states only switch if there is any positive yvelocity.

Code: Select all
if(yvelocity>3)
{
    if(STATE%2==1)
    {
        ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
        STATE=7;
    }
    else
    {
        ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
        STATE=6;
    }
}
yvelocity++;


The code above again only triggers if there is yvelocity, except this time if the yvelocity is greater than 3. The line if(STATE%2==1) is making sure if the state is essentially even or odd. In the state method, generally even numbers are made up of animations facing right, odd numbers are made up of animations facing left. And along with the animations changing, the value of state changes.

And the code on the bottom "yvelocity++;" isn't related to the state method, but it merely means to have yvelocity increase,
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: actor n background

Postby dzuncoi » Wed Jun 06, 2012 9:02 am

yeah, i need time to understand all these things, still have some troubles :) thank u very much :D

ah hey happyjustbecause, in the tutorial, in the "draw actor" event they have 1 code ("state" included) and in "keydown" event, they also have some codes that include "state", i wonder these "state" have any connections ? i think yes, right ? :?
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby skydereign » Wed Jun 06, 2012 4:22 pm

Yes, those are the same variable. The idea of that variable is very important, and pretty simple. The state variable just holds a number that represents something the player can do. For instance, 0 means the player is standing right, 1 means the player is standing left, 2 means the player is running right, and so on.

The switch statement allows you to tell the actor how to react depending on what the actor's current state is. So in a keydown right event, you can tell the actor exactly what you want it to do, depending on what is currently doing. I assume you were looking at my demo of the state method, in which case you might want to read this. http://game-editor.com/State_Method
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor n background

Postby dzuncoi » Thu Jun 07, 2012 9:34 am

yeah, i now understand this method, really simple :D thank u all :D
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby dzuncoi » Thu Jun 07, 2012 2:11 pm

hey guy, i want to ask 1 question, i creat a player n a ground, i also add physical response for the player like this
PhysicalRespons(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.00, 1.00, 0.00, 0.00);
but it doesn't work, there r some positions that make my player fall through the ground, anyone can help me fix it :(
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby skydereign » Thu Jun 07, 2012 3:36 pm

Is the collision event set to repeat? If not, then a constant collision will cause the actor to fall through. Also you need to have the collision event specify all direction or create separate collisions for the different sides.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor n background

Postby dzuncoi » Thu Jun 07, 2012 4:10 pm

aaaaaaaaaaaaaaa thank u guy, i added collision for the left n right side n it's ok now :D
i think it will take me lots of time to use this program effectively :D
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby dzuncoi » Thu Jun 07, 2012 5:58 pm

i have problem again :( how can we differentiate between 4 sides of an actor ? cos i want the player die when he collide with left or right side of an monster n destroy the monster when he collide on the top, but something went wrong, sometimes the player hit the snake head n destroy the snake :( or sometimes the player hit on the top of the snake but he n the snake die together :evil: just 50% right and 50% wrong, s.o help me plz :(
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby skydereign » Thu Jun 07, 2012 6:16 pm

Well normally you use the top side/bottom side/left or right side collisions for this. But the problem is that usually most collisions trigger at least two. You can limit this by using bounding box actors so that the collisions are clean rectangles (making it easier for gE to distinguish the side of collisions).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor n background

Postby dzuncoi » Fri Jun 08, 2012 5:46 am

can u show me more clearly :( i got the idea but dunno how to do it

ar, i did it :D
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: actor n background

Postby dzuncoi » Fri Jun 08, 2012 7:48 am

hey guy, when u make a game n need some animation, u creat them by urselves or u search on internet ? cos i got some animation from internet but it's not as i expected :( but i dont think i can creat animation myself at that time :(
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron