Adding Touch Duration to Game?

Just started using Construct 2? Post your questions here

Post » Mon May 26, 2014 8:11 am

I'm creating an Autorunner game for phones and wanted to add Touch dratiom feature to it. By this i mean i wanted to add a function where the power/height of the players jump is determined by how long the user touchs the screen, so if the user does a quick tap to the screen to jump, it will do a light jump and if its a longer press to the screen, it will be a slightly more powerful jump.

Currently i have set the character to jump the furthest that it can, so i'd like to implement a feature where the player can make shorter jumps by just tapping the screen.

My capx file is much larger than 2mb so i'm unable to post this here.

I don't know if this is possible but would any help with this using the Autorunner Template as an example.

Thanks
Image ImageImage
B
7
S
2
G
1
Posts: 93
Reputation: 1,243

Post » Mon May 26, 2014 10:25 am

You can try 'Every tick' + 'in touching object' -> incrase jump by 1;
and 'on touch end' -> jump; jump = 0;
B
22
S
3
Posts: 74
Reputation: 1,515

Post » Tue May 27, 2014 3:11 pm

Thanks for the reply but thats not working for me, when i do a jump all it does is display the jumping animation which i have without actually jumping.

I'm sure this can be done as many game have this but i just don't know how to do it.
Image ImageImage
B
7
S
2
G
1
Posts: 93
Reputation: 1,243

Post » Thu May 29, 2014 4:09 am

Jump.capx


Set the jump to the smallest jump you want. Then have a "on touch" that adds + 1 to the jump every tick.
You do not have the required permissions to view the files attached to this post.
B
13
S
3
G
2
Posts: 45
Reputation: 2,308

Post » Thu May 29, 2014 2:03 pm

Thanks for the example but its not quite what i'm looking for. With your example, i am able to increase the jump by holding down on the touchscreen/mouse click but this doesn't really work for an autorunner where everything is constantly moving.

I think Canabalt is the best example i could give of how i want to do it. With that, the jumping is based on duration of touch but the highest jump is capped no matter how long the button is pressed, thats is what i'm look for.

Is this possible to do?
Image ImageImage
B
7
S
2
G
1
Posts: 93
Reputation: 1,243

Post » Thu May 29, 2014 2:38 pm

Ok, for that you do:

While touching: make jump
(subevent) On any end touch: Set Y vector to -50(or whatever negative number you want)
B
13
S
3
G
2
Posts: 45
Reputation: 2,308

Post » Thu May 29, 2014 3:01 pm

Thanks, i've tried that. It does work a little better, but does some weird animation at times. It may work better when if i tweak it.

I found another way of doing it by changing the gravity, this way works better but the issue i have is that the jumping only works when i set it for Keyboard buttons. I can't seem to implement this with the touch feature as there is no change in the jump as there is with using a Keyboard.

I've provided a capx file to show what i've done, hopefully you can help with this.
You do not have the required permissions to view the files attached to this post.
Image ImageImage
B
7
S
2
G
1
Posts: 93
Reputation: 1,243


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests