Need help for proper way to do on release for Touch event

0 favourites
  • 14 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Here is what is going on:

    I have a button. When the player touches the button, it changes the image to a highlighted state to show that it has been touched. What I would like to have happen is then when the user releases the button an action happens (like it goes to the page associated to the button).

    Because of the limited touch commands I cannot figure out how to get this to work with the highlight option. There is no option for choosing "on release" of a specific object...which i don't understand why there isn't when there is a choice for when you touch a specific object.

    I can't use "on any touch end" because I have multiple buttons on the page. It has to be the release of that specific button. It's easy enough to set up the button when pressed to go to a page, but the on release just has me baffled with this system.

    I'm sure I can set up some variable type system to see if the button has been pressed and released and so forth but I was hoping there was a simple logic thing I was missing with the touch events, like if I just invert so and so command it will work like I want it.

    Any help for this would be greatly appreciated. This seems like something that would be really easy to do.

  • You can make a variable Boolean, and when you touch that object set the variable to true.

    That way you can have a sub event to "on any touch end" that checks if that variable is true.

  • I figured as much but I was hoping there was something built in. I'm a long time Game Salad user who is trying out Construct for the first time and Game Salad had an "on release" function so it was super easy to set up something like this. Going the variable route means I have to set up variables for every single button that I'm putting into the game. It's not difficult, but it is time consuming and seems like something that should be easily handled through an event.

    Is there really no way to do this through the touch events?

  • You can make a subevent in 'onTouchEnd' and see if the touch ended over your button object.

    IE

    OnTouchEnd

    Touch is over Button

    Do this

    Or check when the touch isn't over the button to reset it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The simplest method would be to add a system wait, and assume that waiting a second or so would be enough time to revert the button, and then go to the other part.

    On touched object, set object frame to 1, wait 0.5 seconds, set object frame to 0, wait 0.5 seconds, do foo.

  • PhoenixNightly:

    I would love to be able to do that...but there is no Touch Is Over event like there is for Mouse. You are either touching the object or not. Unless I'm missing something.

    newt: the thing with trying to do a timer is that if the person moves their finger away from the button without releasing it, it would still trigger the timer because it had been touched...and you don't want that. You want it to trigger only if you have touched and released that object.

  • OK. It can be as complicated, or uncomplicated as you want.

    We're not at the Ikea store tho...

  • Yeah, I gotcha. There are always learning curves jumping to new software and the way things worked in one don't always work in another. Not trying to be difficult here just trying to make sure I'm not missing something super easy since it's all new to me

    I'm using the variable route for now and it works fine I just wish there was an "on object release" choice for touch events. Seems like an oversight to me. Thanks for the help Newt!

  • You can do it this way.

    [attachment=0:1xwzx6zh][/attachment:1xwzx6zh]

  • PhoenixNightly:

    The problem was not the highlighting of the button. I had already set that up the same way your example is showing. The problem was that I needed a way for the button to then do it's thing once you stopped touching it. There is only an option for a global on release, and not an option for an object on release. I've done a work around by using variables I was just hoping there was something built into the touch events that I was missing. Thanks for trying to help. Greatly appreciated!

  • On touch end - and - is touching object

    That should work. It's late and I'm using my phone to type so I cannot confirm first before posting but I'm pretty sure that's the easiest way to do it.

  • Then if you just use 'Is touching' and invert would be like being released. Release is more of a mouse button terminology but is touching and is not touching is the same as press/release.

    But Colludium idea works also.

  • Colludium

    That totally worked. I would never have thought that putting those two together would have done that though. In my head you can't both be touching the button and not touching the button but I guess since technically it does run them in order and is checking for all those things to be true it ends up working out. Thanks for the help!

  • Yeah it works, but it does sound a bit iffy.

    Might get Ashley in here to confirm if its proper usage, or not.

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