How do I change animation ?

0 favourites
  • 8 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • I want to change the animation of a sprite after 2 seconds of holding down a key.

    first (i can)

    -animation1 is play when the key(A) is pressed.

    second (i can't)

    -Keep holding the key(A) to play animation2 after 2 seconds.

    I was born yesterday...

    please explain easily.

  • There are several ways you can do it.

    You can use Timer behavior. On key pressed - start a timer for 2 seconds. On key released - stop this timer. On timer event - play animation2.

    Another option is with a variable.

    On key A pressed : Set variable Charge to 0
    
    Is key A down : Add dt to Charge
    ... Compare variable Charge>=2 : Player play animation2
    
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you want me to give a solution, let me know in the first way. Because I can't read the code.

    The answer I want is. If I keep holding the A key, animation 1 will change to animation 2 after 2 seconds.

    ⑴ A key down

    ⑵ play animation1

    ⑶ keep pressing..

    ⑷ 2 seconds have passed while pressing the A key.then play animation2.

    (If I hold the A key pressed, animation 2 will continue to play.)

    I am a beginner.

    To be honest, I think I can understand it by looking at the event sheet screenshots..

  • I have given you two solutions. You can try either of them. The "code" is the same as events. For example, "On A Key pressed" is an event of the Keyboard object.

    I also suggest you study a couple of tutorials for beginners.

  • you said,

    "..On key released - stop this timer. On timer event - play animation2."

    I didn't ask about execution when a key is released.

  • If you decide to do this with a timer, you will need to stop it when the key is released early. If you don't stop the timer, the animation will still change after 2 seconds, even thought the key is no longer being held.

  • you said,

    "..On key released - stop this timer. On timer event - play animation2."

    I didn't ask about execution when a key is released.

    How are you hoping to create functionality for when a key is pressed down without also checking if the key is no longer pressed down?

  • I don't know coding.

    May I ask for a screenshot of the event sheet?

Jump to:
Order by:
Duplicate Topics
Posts
Views
Last Post
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)