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

Get help using Construct 2

Post » Sun Mar 30, 2014 2:32 am

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
You do not have the required permissions to view the files attached to this post.
B
4
G
1
Posts: 35
Reputation: 595

Post » Sun Mar 30, 2014 3:01 am

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?
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Sun Mar 30, 2014 11:06 am

@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
B
4
G
1
Posts: 35
Reputation: 595

Post » Sun Mar 30, 2014 11:16 am

@eoant , 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
B
4
G
1
Posts: 35
Reputation: 595

Post » Sun Mar 30, 2014 8:59 pm

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.
You do not have the required permissions to view the files attached to this post.
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Sun Mar 30, 2014 9:56 pm

@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
B
4
G
1
Posts: 35
Reputation: 595

Post » Sun Mar 30, 2014 10:04 pm

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
B
4
G
1
Posts: 35
Reputation: 595


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 9 guests