How do I do "Touch Release" on C2 r190?

Get help using Construct 2

Post » Wed Jan 07, 2015 2:20 pm

I searched high and low and there is no up-to-date information on this function.

I have a platformer and I want to cut the jump mid air if touch is released. On keyboard/gamepad it's more than easy to do:
Code: Select all
- On Key Press -> Jump
- On Key Release && Is Jumping -> Fall


However there's no release on touch... I've 3 objects for controls - "TouchLeft", "TouchRight" and "TouchJump". This first part is easy
Code: Select all
- Is Touching Object "TouchJump" -> Jump


Now here's what I got for the second part so far, but it's all faulty:
  • Code: Select all
    On any touch end && Is Jumping -> Fall /* works, but that means that if the player releases "TouchLeft" the jump will be cut also */
  • Code: Select all
    Is NOT Touching Object "JumpTouch" && Is Jumping -> Fall /* Buggy on touch, breaks keyboard and gamepad controls */
  • Code: Select all
    Is Touching Object "TouchJump" -> Is NOT Touching Object "TouchJump" && Is Jumping -> Fall /* This does not work for obvious reasons, but I decided to share it nevertheless */

Any ideas?
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757

Post » Wed Jan 07, 2015 2:28 pm

On any touch end && is Touching Object?

EDIT//
Alternatively an On any touch end sub-event within your jumping event should work.
Last edited by Elliott on Wed Jan 07, 2015 2:36 pm, edited 1 time in total.
B
62
S
23
G
10
Posts: 647
Reputation: 10,578

Post » Wed Jan 07, 2015 2:30 pm

So you want to stop the jump prematurely if you release the touch? Sorry it's a little confusing. Not sure why you cant just use touch end?
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Wed Jan 07, 2015 4:31 pm

@Elliott this is pretty much like my first suggestion. It works, but if you release either left or right (most of the time the player uses those to navigate where he/she is landing) that will cut the jump short.

TheWyrm wrote:So you want to stop the jump prematurely if you release the touch? Sorry it's a little confusing. Not sure why you cant just use touch end?


Yes, that's exactly what I'm trying to do - stop the jump when the jump object is no longer touched, but it seems impossible or at least not straight forward with the given options.

Wherever I looked people talked about this Touch End option, but I don't have such a thing, not just Touch End. I've On Any Touch End that triggers when any of my 3 touch objects is released and On Nth Touch End that triggers on touch count not on object.
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757

Post » Wed Jan 07, 2015 4:50 pm

Okay, doing this from memory so it won't be perfect, and I'm pretty sure I'm adding an extra step, but try this:

Create a global variable called jumpTouch.
When you touch your jump button, run your actions as normal, with the additional action at the top set jumpTouch to TouchID.
Add an "on nth touch end" event, use the jumpTouch variable as your TouchID; then run your falling events.
B
62
S
23
G
10
Posts: 647
Reputation: 10,578

Post » Wed Jan 07, 2015 9:28 pm

@Elliott this does work, but it bugs out on a special occasion - if the object is tapped ever so slightly for a fraction of a second there's no time for the variable to be created and the event executed so a full jump is performed.

I'm attaching a file so you can see for yourself. Try tapping the mouse button veeery slightly.
You do not have the required permissions to view the files attached to this post.
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757


Return to How do I....?

Who is online

Users browsing this forum: humanescape, Klarner, worm1 and 27 guests