How do I make touch activate and deactivate events

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

  • Try Construct 3

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

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

  • 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

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

  • On Touch/Click if Object boolean is true

    Action set boolean false

    ELSE

    Action set boolean true

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