Page 1 of 1

Can't make animation sprite stop moving.

PostPosted: Mon Jan 12, 2009 9:53 pm
by LucasA33
I have placed a sprite in my game, as its a main character.... One prob. Its never going to stop moving... I want it to move, only when I press a key.... Help?

Re: Can't make animation sprite stop moving.

PostPosted: Mon Jan 12, 2009 9:59 pm
by Quill
With the keydown you change the animation and make the xvelocity = 5 or similar, as you already know. The way I made him stop running was by adding a key up event to that actor which changes the animation to the resting one, and make the xvelocity = 0

Does that help or should I put the process in more detail?

Re: Can't make animation sprite stop moving.

PostPosted: Mon Jan 12, 2009 9:59 pm
by LucasA33
I think ill need more detail

Re: Can't make animation sprite stop moving.

PostPosted: Mon Jan 12, 2009 10:09 pm
by LucasA33
oh I mean, The sprite, its changing animatines every second.... It shows the Sprite running, when its not.

Re: Can't make animation sprite stop moving.

PostPosted: Tue Jan 13, 2009 12:17 am
by skydereign
This can get relatively complicated... There are moonwalk demos that will help get rid of all moving errors. A simple fix, which does not prevent moonwalking, is on the keyup event, change animation to your standing sprite. Or if you don't have a standing sprite, change the animation to your run right sprite and stop it.

Re: Can't make animation sprite stop moving.

PostPosted: Fri Jan 16, 2009 4:34 pm
by Quill
Well, not meaning to be patronising or be big headed (for I know I'm not good at this program) but I thought that was asimple fix by using a keyup event changing the animation.

As for moonwalking, all I did was use the running sprite (I'm using the same sprites as you Lucas) and in an image editing program flipped the image horizontally.

Then I used that as an animation for running left and bascially did the same as running right, but changing the animation to the running left one and added another event that made:
xvelocity = -5
or similar.

There is a much neater way of putting most of this into a few scripts but I haven't quite done that yet

Re: Can't make animation sprite stop moving.

PostPosted: Fri Jan 16, 2009 11:52 pm
by skydereign
It depends on what you want. Did you try pressing down left and then right and then releasing right, and such? Adding up and down also increases the confusion that can arise. This problem does not matter if you use most controllers, like a PS3 controller as you can't press left and right at the same time.

Re: Can't make animation sprite stop moving.

PostPosted: Sun Jan 18, 2009 2:22 pm
by paperboy321
Try looking at teh tutorials menu on the top bar on game editor.

Re: Can't make animation sprite stop moving.

PostPosted: Sun Jan 18, 2009 6:27 pm
by DST
Note that xvelocity is simply a way to 'store' frame velocity, it is an alternate for normal speed (x+=5;)

Velocity isn't needed when the action is occuring each frame (i. e. draw actor, repeated kepress, etc.)

Velocity is for building up speed, its best used on single triggers or gravity, where we want to build up velocity or let it sustain after the event is over.

So if you use velocity in a keypress, you'll need an action (like keyup) to stop the velocity; if you use x+=5; in a keypress, you don't need a keyup. It stops when the event stops. For most situations, x+= is much better suited than velocity, because most game movements are immediate, rather than gradual.

Also note that velocity, x+=, and angle+directional velocity are interchangeable.
You can say x+=5;, then say if(xvelocity==5) or (if angle==0) because all three forms of speed are interchangeable in GE.

So its

x+= normal movement
xvelocity= sustained or builtup movement
angle & directional velocity= for objects than move in any direction instead of only 4.

Hope this helped.