Why can't I change an instance variable by using a touch condition?

0 favourites
  • 6 posts
From the Asset Store
Surena Touch
$1.25 USD
50% off
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • Why doesn't such a structure work?

    I want to select objects and deselect them. To then apply effects only to the selected objects.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Events run top to bottom, your event runs like this:

    1. Touch object

    2. Object is not selected -> set selected

    3. Object is selected -> set not selected

    Add an "else" to the second condition to fix it.

  • Hi, because on event 3 “isSelected” is false so it sets to true ( now it’s true), then when it runs event 4 it’s already true because it was set on event 3 to true, so it sets to false again so it disables the effect again.

    You should do something like this instead:

    EDIT: You can use an “Else” on event 4 instead

  • WackyToaster

    Add an "else" to the second condition to fix it.

    Sorry, didn't quite understand "else" with what condition?

    You should do something like this instead:

    Toggle! Of course! It works, thank you! :) Hopefully this logic will help me identify the first and second selected objects to swap them as inventory items.

  • Adding an "else" will kinda combine the 2 actions together, so your logic would look at the first event "IsSelected", and if you use an "else" on the next event, then those two events work like "is selected? Do this. Otherwise, do this other stuff for when it's not selected".

  • Adding an "else" will kinda combine the 2 actions together, so your logic would look at the first event "IsSelected", and if you use an "else" on the next event, then those two events work like "is selected? Do this. Otherwise, do this other stuff for when it's not selected".

    I got it, cool! That works too. Thank you!

    And maybe someone knows why the second tap on the sprite does not work immediately, but after 1 second? I don't mean the reaction to the tap, I mean that the second time you tap on the sprite, you have to tap several times to active it.

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