How do I make touch activate and deactivate events

Get help using Construct 2

Post » Wed Apr 08, 2015 1:01 am

Hi, I'm making a mobile platform game and I want the tap on object to activate an event at that object and if I tap it again I want it to deactivate that event, I tried to do that with groups and a boolean variable at that object but when I activate that event I can't deactivate it again. Sry for my english, I'm brazilian.
Last edited by Jairoviski on Wed Apr 08, 2015 1:28 am, edited 2 times in total.
B
2
Posts: 2
Reputation: 154

Post » Wed Apr 08, 2015 1:23 am

add a boolean instance variable to your object.

Then on Touch/Click you can toggle the boolean to true or false

Then simply add another condition to event you want to turn on/off.

i.e.

Event Condition
AND
Object boolean = true
THEN do Actions...
B
66
S
20
G
8
Posts: 987
Reputation: 10,119

Post » Wed Apr 08, 2015 1:26 am

So, I tried to do that and my boolean goes to true, but when i try to tap my object again to set it to false nothing happens, the boolean stay true forever
B
2
Posts: 2
Reputation: 154

Post » Wed Apr 08, 2015 1:41 am

If you have events that are taking mouse and touch input they can mess each other up. To fix it select the touch object in your object list to bring up the properties and un-check Use Mouse Input. Other than that it is as simple as Jobel as said.

Assign the object a Boolean Instance Variable.

Then in the events do an On object touched-Toggle Boolean.

Run in Debug with the object selected so you can make sure the Instance Variable is being toggled. It should be switching from 1 to 0.

If that is working you know the touch events work.

All else fails upload a .capx to a dropbox and share a public link so people can take a gander at what is exactly going on in your code.
Image
B
33
S
16
G
2
Posts: 185
Reputation: 4,036

Post » Wed Apr 08, 2015 1:43 am

On Touch/Click if Object boolean is true
Action set boolean false
ELSE
Action set boolean true
B
66
S
20
G
8
Posts: 987
Reputation: 10,119


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests