Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / using an animation and movement

Author
Message
sprcoll
12
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 6th Apr 2014 20:56
Hello all together,
i hope my english is good enough for this post. I have the following problem, i want to move my animation-sprite if i press a key and play the animation at the same time. it doesn´t work. i use the following code:

soldieranim_I = createsprite (1)
setspriteposition (soldieranim_I, soldier_x#, soldier_y#)
setspriteanimation (soldieranim_I, 50, 100,2)
if getrawkeystate (37)

playsprite (soldieranim_I,5,1,1,2)
soldier_y#=soldier_y#+1

endif

How does it work?
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Apr 2014 00:32 Edited at: 7th Apr 2014 00:40
Try changing this bit:



To this:



Basically, you are calling PlaySprite every loop which is effectively restarting the animation. You need to check to ensure the animation isn't already running...

EDIT: For the movement part, I can see you are increasing your Y position (soldier_y#), but are not updating the sprite position. You will need to add the SetSpritePosition command with the new X/Y values to move the sprite.
sprcoll
12
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 7th Apr 2014 21:57
OK, thank you. i can´t test it today, so i will try it tomorrow.
In my example i have a line with the setspriteposition.

Login to post a reply

Server time is: 2024-11-25 03:46:10
Your offset time is: 2024-11-25 03:46:10