key pressed and is down

Get help using Construct 2

Post » Tue Mar 31, 2015 1:59 pm

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!
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Tue Mar 31, 2015 2:03 pm

Should be as simple as:

on key pressed start timer
on key released stop timer
on timer - special attack
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Mar 31, 2015 2:20 pm

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.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Tue Mar 31, 2015 4:21 pm

ryanrybot wrote: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
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Tue Mar 31, 2015 4:51 pm

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Mar 31, 2015 5:18 pm

LittleStain wrote: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?
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Tue Mar 31, 2015 5:22 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Mar 31, 2015 5:50 pm

LittleStain wrote: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!
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Tue Mar 31, 2015 7:01 pm

So are you trying to have it so when you do a normal attack a few seconds later a special attack comes out?
B
17
S
4
Posts: 86
Reputation: 1,211

Post » Tue Mar 31, 2015 7:15 pm

mikewalton206 wrote: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.
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests