How do I Toggle global variable value on touch?

0 favourites
  • 3 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi, I want to toggle speed of object on tapping anywhere on screen. Initially I have global variable "speed" set to 200. I wrote an event like

    1. On tap gesture & Speed = 200 --> set speed to 100

    2. On tap gesture & Speed = 100 --> set speed to 200

    It seemed to do nothing, then I wrote

    1. On tap gesture & Speed = 200 --> set speed to 100

    2. On tap gesture & Speed = 100 --> set speed to 300

    Now on one single tap gesture, the speed is being set to 300.

    I wrote the same thing with Keyboard:any key pressed. The same thing is happening. Can anyone explain whats happening here and a work around.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When line 1 runs, you set the variable to 100. Then line 2 runs, the variable is 100, so sets it to the other value. Change your events to check On tap first, then use sub events for the speed decoding using Else on subsequent items so that the variable is only checked once.

    On tap gesture

    -> Speed=200 --> set speed = 100

    -->Else

    -->Speed=100 -->set speed = 300

  • Thank you, much appreciated. Did the job.

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