complex button commands

  • 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.

  • 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.

  • plinkie

    ok thanks. that sounds simple enough.

    what specific condition or action should I use for starting/making a timer?

  • 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

  • plinkie

    <img src="http://neuropod.net/imagehost/uploads/6ae9e76727fb0273baacbeee0f6bce80.png" border="0" />

    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.

  • 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.

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • plinkie

    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.

  • 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!

  • plinkie

    when I directly open it after downloading

    <img src="http://neuropod.net/imagehost/uploads/781b4326255f3f47e4681d89a1032b94.png" border="0" />

    when i save it first then open it from the file location

    <img src="http://neuropod.net/imagehost/uploads/e677fe2d3355947b81562a5c49b4d03b.png" border="0" />

  • Sec. I like to use the beta!

  • I'm not sure how to enable the file in previous version. I install r139 but no way to open project file or .capx. Are you able to update r145? : P

  • <img src="https://dl.dropboxusercontent.com/u/49548363/screen1.png" border="0" />

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

    https://dl.dropboxusercontent.com/u/49548363/run_updated.capx

    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!

    @plinkie

    <img src="http://neuropod.net/imagehost/uploads/9699cf99d62cd675acaeed0a814c293d.png" border="0" />

    I disabled my run and movement groups and added those codes.

    Here's what happens:

    I double tap right arrow (and not release the press on the second tap), player uses Run animation's first frame for about 1 second, then goes back to walk.

    so the problems are it never animates the Run and it goes back to walk after a second.

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