GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

press key to play animation

emojiemoji Posts: 31Member, PRO

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

  • tatiangtatiang Posts: 11,401Member, Sous Chef, PRO, Senior Sous-Chef

    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

  • tatiangtatiang Posts: 11,401Member, Sous Chef, PRO, Senior Sous-Chef
    edited July 12

    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

  • rainwaterstudiosrainwaterstudios Posts: 152Member, PRO

    @tatiang said:
    When [key is pressed]
         Timer After 0 seconds [run to completion CHECKED]
              Animate

    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

Sign In or Register to comment.