How do I "Two Actions with One touch" for advanced users

0 favourites
  • 7 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • Guys !

    i have set a capx sample, to allow you to check what is wrong in my code.

    my problem it's simple :

    as designed for mobile and touch input, my game is an auto runner, and i need to set two actions with the touch

    by defaut my player run then,

    if i tap , the player should jump on landing back to run

    if i touch and hold "mean in touch" i need to have the player who attack, then back to run"

    for a reason i ignore even if i use the else function , i can't have something robust who work every time

    i would really appreciate if an advanced construct users could check my capx to fix my wrong code

    my capx is commented and very explicit with debug function , but the shorter as possible

    thanks really to anyone who will fix my problem

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm pretty sure I can help you, but I just need to verify a few things. Do you want the player to attack mid-jump, or do you want a long touch to trigger an attack from the ground?

  • EgoAnt ! thanks , so to answer to your question,

    the attack action in my case should only take place "from" and "on" the ground , which mean, i should not see the player jump and attack at any moment in the air. so i guess the answer is a long touch to trigger the attack

  • , just remember, the concept is

    if i touch i should jump

    or

    if i (touch and hold) i should attack on ground only

    thank you really much for your help !!!! :p i'm eager to view how you try to fix this

  • Okay, I think this should work. I added two global variables, TapThreshold and AttackTriggered. Basically the way it works is when the touch starts intouchtimer starts going up. If the player releases the touch before the timer exceeds the TapThreshold (currently set at 10 frames) then a jump is triggered. Every frame it checks to see if the intouchtimer has gone over the TapThreshold and if it has then an attack happens, even if they haven't finished their touch.

  • EgoAnt

    thanks i've just checked ! it work but only on ground mean, while i'm jumping if i'm in touch , the player switch between jump to Attack,

    could we make impossible to attack while jumping and i would say even in the air ?

    thanks again

  • ok fixed , just need to find a way now to stop the jump at any touch end and set the vector y to vectory y/2

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