key pressed and is down

  • Hi all,

    i want to make a normal attack with pressing a button and then with holding the same button, i need to make my character to make a special attack (without making the 1attack when holding). I messed with timers and with on press and "is down" but somehow i can't seem to do this right. Thanks!

  • Should be as simple as:

    on key pressed start timer

    on key released stop timer

    on timer - special attack

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just worked on an identical mechanic and didn't find an acceptable solution yet, so I just left it to have a normal attack when the button is held down for now.

    You could do it by having the normal attack activate on button release instead of button pressed, but it doesn't feel quite right.

    Another thing to try is setting a timer on button down, so if the button isn't released by 0.1 seconds

    (or some other small amount of time)

    start charge, else do a normal attack. That might work, but I have yet to try it.

  • I just worked on an identical mechanic and didn't find an acceptable solution yet, so I just left it to have a normal attack when the button is held down for now.

    You could do it by having the normal attack activate on button release instead of button pressed, but it doesn't feel quite right.

    Another thing to try is setting a timer on button down, so if the button isn't released by 0.1 seconds

    (or some other small amount of time)

    start charge, else do a normal attack. That might work, but I have yet to try it.

    i would like to try that however how to make the event = if the button isn't released by 0.1 seconds -> do this

  • Like I said before:

    add the timer behaviour

    on button pushed start timer for 0.1 seconds

    on button released stop timer

    button on timer - special attack

  • Like I said before:

    add the timer behaviour

    on button pushed start timer for 0.1 seconds

    on button released stop timer

    button on timer - special attack

    LittleStain, im trying to get it right. But when the timer ends, i need to store the time and compare it. Not set it to 0 on button released?

  • The timer is just a countdown.. on timer means that the countdown is done..

    There is no need to store the time..

    Use on timer as the trigger event to start your special attack..

    stopping the timer on button released makes sure the on timer event isn't triggered if the button is released before the timer ends..

  • The timer is just a countdown.. on timer means that the countdown is done..

    There is no need to store the time..

    Use on timer as the trigger event to start your special attack..

    stopping the timer on button released makes sure the on timer event isn't triggered if the button is released before the timer ends..

    Could you please provide a capx or write the events? I can understand what you mean but i can't seem to write it in form of events...

    many thanks!

  • So are you trying to have it so when you do a normal attack a few seconds later a special attack comes out?

  • So are you trying to have it so when you do a normal attack a few seconds later a special attack comes out?

    Hi mikewalton,

    no im trying to do, when you hold the attack button, a special attack starts without trigering the normal attack. And if the same key is just once pressed, then a normal attack starts without the special attack.

  • I would post a good pic and or video link that could help you out a little bit but my rep isn't high enough to do that yet lol also do you have the actual special move effect and or images already made up and in the proper folders? Because you need the animations of whatever the player will do or shot out when the special move is triggered. For example if the player is gonna do some kinda crazy swinging sword attack you'll need the sprite sheet of your character in all the frames of motion he's gonna be doing. If it's gonna be like a thunder ball attack you'll need a sprite sheet of the thunder attack. Most things like that have like 9 frames of the thunder ball attack and When you upload these you have to do it as a new animation not just a sprite or you'll just get one image instead of like 9 or however many frames your attack has

  • mikewalton, yes i have these prepared and finished. Its basicaly just the technical aspect of running them.

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