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

0 favourites
  • 6 posts
From the Asset Store
A full Spriter-based Platformer engine for C2 or C3
  • 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:

    - On Key Press -> Jump
    [ul]
    	[li]On Key Release && Is Jumping -> Fall[/code:m7qzts7u][/li]
    [/ul]
    However there's no release on touch... I've 3 objects for controls - "TouchLeft", "TouchRight" and "TouchJump". This first part is easy
    [code:m7qzts7u]- Is Touching Object "TouchJump" -> Jump[/code:m7qzts7u]
    
    Now here's what I got for the second part so far, but it's all faulty:
    [ul]
    [li][code:m7qzts7u]On any touch end && Is Jumping -> Fall /* works, but that means that if the player releases "TouchLeft" the jump will be cut also */[/code:m7qzts7u][/li]
    [li][code:m7qzts7u]Is NOT Touching Object "JumpTouch" && Is Jumping -> Fall /* Buggy on touch, breaks keyboard and gamepad controls */ [/code:m7qzts7u][/li]
    [li][code:m7qzts7u]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 */[/code:m7qzts7u][/li][/ul]
    
    Any ideas?
  • On any touch end && is Touching Object?

    EDIT//

    Alternatively an On any touch end sub-event within your jumping event should work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

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

    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.

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

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

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