while holding down the key / repeat sprite animation / key is down problem

0 favourites
  • 12 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • (written with a translator)

    I applied "key is down" instead of "key pressed" for a reason.

    If I set it to "key is down" and keep holding down the key the (AnTo_1)animation will loop over and over again. It's fine. but it does not change to another (An1)animation at the set time.

    I want to know how.

    please let me know.

    (There is a reason, so I want to do it in "key is down" ways.)

    (I'm a beginner, A screenshot would be more appreciated.)

  • Keyboard -> is down is being checked every tick, so lets say that your game is running at 60 fps, this condition is being checked 60 times per second and its true every time, so every second it is going to set your actions about 60 times.

    Its not playing An1 because you are reseting the timer W every tick that is being checked, and when you release the key it will not reset and play after 2 seconds..

    You need to change this logic, tell us what is your C sprite and what are you trying to achieve

  • This is a prototype and I will insert a character into C later. It's just a moving action.

    When I press a key, it performs a basic action, but if I keep holding down the key without releasing, a special action is performed.

  • Try this

  • is this right?

    It only moves by 2 pixels and all animations don't work.

  • is this right?

    It only moves by 2 pixels and all animations don't work.

    You have to invert both sub conditions, right click on it: invert, see on my pitcure it has an X in front of it, it means: invert

    If you hold the -> key, it will move forward 2 pixels

    Sub conditions: if there is not a timer "W" already running: Do start it with 2 seconds

    if the animation "An1" is not playing, Play "AnTo_1"

    On timer "W" it is going to play "An1"

  • It has a few problems but It worked fine.

    really thank you.

    As a reference to your answer, I added an event. Everything is fine, but there is a few problems.

    here

    • Press the → key : (AnTo_1)Animation is played from frame 1 to frame 4. (ok fine)

    but, Is it possible to disable the → key or all keys while (AnTo_1)animation is playing?

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    • If i continue to holding down the → key, the (An1) animation will play until the last frame,

    (ok fine)

    then stop and go back to frame 1 after 2 seconds. If i don't release the → key, play after 2 seconds and repeat after 2 seconds. over and over again.

    I want to give a delay of 2 seconds only when changing from (AnTo_1)animation to (An1) animation.

    When repeating, I want (An1) animation

    to repeat without a delay of 2 seconds.

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    • When I short press the A key, the (AnTo_1) animation plays once from frame 1 to frame 4, stops at the last frame. (ok fine)

    but, Is it possible to change to an (idle) animation after playing to the last frame?

    also the same, is it possible to change to an (idle) animation after the last frame of the (AnTo_1) animation has finished playing?

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    Sorry for the late reply. It took a while to make and test several changes.

    Character setting is important, but it's hard for me because im a beginner. Your answer is very helpful. I would really appreciate it if you could let me know.

  • Send me a msg on discord, I will try to help you

    KryptoPixel#1694

  • I don't have an account.

    I'm really sorry, but I think here is enough,can I ask for an answer here?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, its not a problem but I need more information to visualize the whole mechanics.

    Can you describe better what is your character, how it should move, what are you expecting of each movement/key, so I can think of an approach for the answer?

    Example:

    "Its a side character that moves left/right using arrows keys.. if the arrow is held for 2 seconds it does this or that.. If nothing is pressed it should play an idle animations.."

    As much information as you could provide

  • I think this is what you need

  • Sorry for the late reply.

    After many testing until late yesterday, I reduced the problem by adding one more key is down condition. But there are still unresolved problems.

    And when I checked the code you suggested, the 2 second delay problem disappeared. And by adding a release condition at the bottom, the idle animation problem was also solved.

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    Here is an unresolved problem.

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    • Press the → key : (AnTo_1)Animation is played from frame 1 to frame 4. (ok fine)

    but, Is it possible to disable the → key or all keys while (AnTo_1)animation is playing?

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    If i continue to holding down the → key, the (An1) animation will play until the last frame,

    (ok fine)

    then stop and go back to frame 1 after 2 seconds. If i don't release the → key, play after 2 seconds and repeat after 2 seconds. over and over again.

    I want to give a delay of 2 seconds only when changing from (AnTo_1)animation to (An1) animation.

    When repeating, I want (An1) animation

    to repeat without a delay of 2 seconds.

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    When I short press the A key, the (AnTo_1) animation plays once from frame 1 to frame 4, stops at the last frame. (ok fine)

    but, Is it possible to change to an (idle) animation after playing to the last frame?

    also the same, is it possible to change to an (idle) animation after the last frame of the (AnTo_1) animation has finished playing?

    ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

    Thank you both so much.

    The rest of the problem will be asked after testing.

    God will be pleased to see you both.

    thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)