howto move an actor back and forth ?!
r0x0r
Member Posts: 9
title. Basically what I want to do is to move a sprite every X seconds -32px on Y-axis and once there, wait Y milliseconds and return to its origin. Thanks!
Comments
Timer: Every X seconds Interpolate self.position.y to self.position.y-32.
After X seconds, Interpolate self.position.y to self.position.y+32
Is that what you're looking for?
Well maybe I should expose the goal better, I'm trying to achieve a movement that would be similar to an animal that takes his head out of his hole (aka home :P) and then goes back in (all happens relatively fast). I tried many things with 'move to', 'move', 'rule', 'timer', I don't know what to do honestly I can't manage to do that easy task..
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I think the problem is the documentation that doesn't explain the objects we can use for "programming". I am a C developer and I tried many logic things. Let me show you one.
- create Animal (actor) with two attributes, originY and destY as real.
- add Timer after 1sec (for testing going UP).
- in Timer: add Change Attribute self.originY to self.Position.Y
- in Timer: add Change Attribute self.destY to self.Position.Y-32
- in Timer: add Rule when all conditions are valid.
- in Rule: add Attribute self.Position.Y >= self.destY
- in Rule: Move
Fail. The actor never stops, why ? Self.Position.Y not updated every frame ? How to Debug (other than adding Display Text objects) ?
Next time, the minimum that someone can do who wants to help is to directly point to the information instead of saying "RTFM" (totally useless and insulting).
You will have to forgive us we have been dealing with many for the last 4 months who come here and expect the forum users to tell them how to make their games because there is no code and its still not easy enough for them. So please do not disrespect the users of this forum with your attitude that we should cater to your every need. we are here giving help for free so don't abuse it by expect us to lay your rules out for you on easy tasks.
http://gamesalad.com/wiki/how_tos:gsc_pacing
Gamesalad Wiki -> How To -> Movements -> How to make an actor pace back and forth
http://gamesalad.com/wiki/how_tos:gsc_pacing (same link sparkzilla posted)
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
/* That's the Timer behavior */
time_begin = getLocalTime();
do {
time_end = getLocalTime();
} while(time_end < time_begin+1000); // as it if was in ms, wait 1sec
/* Change Attribute behavior */
originY = actor.position.Y;
destinationY = actor.position.Y - 32; // go up 32px
/* Rule */
while (actor.position.Y > destinationY) {
actor.move(DIRECTION_UP, DESIRED_SPEED);
}
sparkzilla, thanks for the advise but it stills the same problem, you stop movement based on time, I need to stop movement at a desired Ypx (origin Y - 32 in that case)
you could probably achieve what you want using interpolate if it is only one actor.
rule:
when self.position.y = 80 (wherever you want it really)
timer: after 5 seconds
interpolate self.position.y to 68
linear movement over 2 seconds (up to you again)
then another rule:
when sefl.position.y=68
timer: after 5 seconds
interpolate self-position.y to 80
linear movement over 2 seconds again
This will keep moving back and forward between the positions and rest for 5 seconds at each point.
thats what I was thinking to0. just not really willing to help someone who's not willing to help themselves.
StutsApps: can you provide an example that works, because all the ways I used were supposed to work, so I bet yours won't work too.
Also, after X hours of trial and fail gamesalad becomes extremly slow, I guess there are tons of memory leaks, it becomes unusable.
heres a demo smart one. Change the number in the timer to change the time it takes to move back up after going down, and change the duration in each of the interpolate rules to control how fast or slow it moves up and down.
have fun
Thanks For Sale if you'd like to see how I did it. Of course I would have just told most people who asked in a civil non rude sort of way.
___________________________________________________________________________________
GS BubbleBall Template HERE!!
Stacks Level Selection Template HERE!!
AppSolute Entertainment on Facebook