complex button commands

Get help using Construct 2

Post » Sun Sep 29, 2013 10:51 am

How do you program a condition for a button like

press down then press right then press z (they should be in order, but not all pressed at the same time?

and they should be pressed in order within a time of 2 seconds or it won't be considered by C2

This is like a button for a super attack.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Sep 29, 2013 12:31 pm

Set up a variable that you add to. Press down(+1), press right(+1), press z(+1). Start a timer of 2 seconds upon pressing down. If variable = 3 within 2 seconds then perform attack. Logic will be something like :

-------
On Down Pressed
Start 2 second timer
+1 to Counter
On Right Pressed (If Counter=1)
+1 to Counter
On Z Pressed (If Counter=2)
+1 to Counter
-------
Every Tick (If Counter=3) > Perform Attack
-------
On Timer Ending > Counter=0
-------

That is how I would do it and it should work.plinkie2013-09-29 12:32:20
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Sun Sep 29, 2013 1:04 pm

@plinkie

ok thanks. that sounds simple enough.

what specific condition or action should I use for starting/making a timer?
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Sep 29, 2013 1:08 pm

You add a timer behaviour to an object, probably the player in this case. Then the timer actions become available on the event sheet. Use OnTimer for when timer ends and use Start Timer to begin the timer
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Mon Sep 30, 2013 2:15 pm

@plinkie



This is a RUN supposed to be done by double tapping right when facing right (or double tapping left when facing left).

Run is an additional animation. The default animation for platform moving left and right is "Walk" animation.

The intended button command is:
double tap right arrow but the second tap will be hold pressing right arrow. when I release the right arrow, it goes back to stance (or what people call IDLE).

It is not working.

Right now, when I double press right arrow (and not release the press) the player still uses "Walk" animation.sgn152013-09-30 14:16:46
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Sep 30, 2013 3:17 pm

My guess is that ButtonCounter goes to 3 here, +1 for press right and +2 for on pressed. You should only be adding one each time if you later check ButtonCounter =2. For debugging you can set up a text object and set text every tick to ""&ButtonCounter, just to make sure you're pressing the arrow fast enough and ButtonCounter is changing.
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Mon Sep 30, 2013 3:35 pm

@plinkie
is the counter variable a local variable or instance variable?

I'm getting crazy just trying to figure out this run. Can you be more specific on what's wrong with my code?

I know I made a mistake in the picture (add 2 to counter when the previous event already had a "set counter to 1"). I fixed that and it still doesn't work.

Please help. thanks.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Sep 30, 2013 3:41 pm

If you send a simplified .capx of the logic then I can fix it for you. Also if WALK is overriding it, I need to see how you set up the trigger for WALK anims as that is probably where half the issue is.plinkie2013-09-30 15:42:30
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Mon Sep 30, 2013 3:50 pm

@plinkie

http://www.sendspace.com/file/1rrmpp

I have edited it further, anyway, do check the "Run" group at the bottommost part of the event sheet.

I am only working at Run (Right) at the moment. I thought that if and when I make it work, I can just copy it and change the right arrow to left for the Run (Left) group.

The Walk is under Player ---> Movements

Please ignore the other events in the events sheet. Those are for enemies and stuff.sgn152013-09-30 15:58:28
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Sep 30, 2013 5:02 pm

I have added some logic at the bottom of the event sheet
here

There are some bugs you need to iron out and also you will need to add it into your existing logic as I disabled the movement groups to get it working. From the logic that exists you seem to know what you're doing though so shouldnt be a problem.

Some key things to notice. The RunCounter variable goes to 2 instantly so I set up a 'Can Double Tap' thing. This allows the user to double tap within 1 second. Check the text object to see how it updates with taps. Also you will notice that Run automatically cuts out when the timer expires, you'll need to set up some logic that detects if the player is running when timer ends so it doesn't instantly set back to Stance. Also the Run animation isn't working properly, which I assume is because it's being overriden by something however you had Run working before so this shouldn't be a problem for you. It is definitely triggering Run though! :)

Hopefully this has helped. Any more questions, send them on! plinkie2013-09-30 17:03:31
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, ignaciosimo, nickar and 43 guests