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

Discussion and feedback on Construct 2

Post » Fri Apr 04, 2014 9:53 pm

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.
B
4
Posts: 11
Reputation: 247

Post » Fri Apr 04, 2014 10:06 pm

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.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Fri Apr 04, 2014 10:12 pm

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?
B
4
Posts: 11
Reputation: 247

Post » Fri Apr 04, 2014 10:13 pm

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
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Fri Apr 04, 2014 10:17 pm

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.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Fri Apr 04, 2014 10:27 pm

@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.
B
4
Posts: 11
Reputation: 247

Post » Fri Apr 04, 2014 10:45 pm

OK. It can be as complicated, or uncomplicated as you want.
We're not at the Ikea store tho... ;)
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Fri Apr 04, 2014 10:54 pm

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!
B
4
Posts: 11
Reputation: 247

Post » Sat Apr 05, 2014 2:42 am

You can do it this way.
TouchExmple.png
You do not have the required permissions to view the files attached to this post.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sat Apr 05, 2014 2:51 am

@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!
B
4
Posts: 11
Reputation: 247

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests