variable reset - problem

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi,

    My goal is: when you press the left arrow key, an instance is created randomly to one of two specified positions.

    I use a global variable and a local variable. The global variable defines the left arrow key has been pressed, and the local variable is used to choose one of two positions.

    I added a "reset global variables" event. Despite this, it seems that the time between the change in value of the variable and reset is long enough to create multiple instances instead of one. I do not understand why.

    Here you can download the if you want to take a look.

    [www.norab.fr/images/reset_test.capx]

    Thank you for taking the time to read my rough english.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't reset globals every tick! Just set validate to 0 after decoding it.

  • Thanks for your answer, but infortunately the problem is still there. If I set "validate" to 0 before instance is created, instance is just not created, and if i do it after instance creation, it still create several intance instead of only one...

  • You are using key is down - do you want on key pressed? Otherwise, I don't follow what you are looking for.

  • My post didn't take so here it is again, Don't "reset global variables"

    Keyboard > Left Arrow is Down > System > Set Validate = 1

    ________________________________ > System > Wait 1.0

    ________________________________ > System > Set Validate = 0

    or

    Keyboard > Left Arrow is Released > System > Set Validate = 0

  • This is it!

    I fixed my problem by using "key is pressed" instead "key is down".

    Thanks for your help!

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