press key to play animation
emoji
Member, BASIC Posts: 66
Hi, quick question for all you guru out there! So I made me a simple testing game where user press certain keyboard and the player would perform certain animation but for some reason, if there are like 5 or more frames in an animation, I have to hold the key down for a few seconds in order for the animation to complete otherwise the animation just stop without completing the animation.
Comments
When [key is pressed]
Timer After 0 seconds [run to completion CHECKED]
Animate
The run to completion checkbox will force the animation to complete even if the key is released before it would normally complete.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Another way to do this is:
When [key is pressed]
Change attribute game.startAnimation to 1
When attribute game.startAnimation is 1
Animate
And then manually reset game.startAnimation to 0 after the animation has completed. For example, When attribute self.Image is [filename of image used for last frame of animation], change attribute game.startAnimation to 0.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You can actually omit the Animation behavior altogether if you want;
When [key is pressed]
Timer: After 0 seconds [run to completion CHECKED]
Timer: For 3 seconds
Timer: Every .1 seconds
Change Attribute self.image to self.image+1
To reset the animation back to its first frame when finished, add a rule:
if self.image is 30
Change attribute self.image to 1