0 Favourites

individual timer on instances

This forum is currently in read-only mode.
  • I have several instances of an object, an each of them have a text over them that counts down, sort of like "bomb timers" for each instance. I made an example cap: http://www.mediafire.com/?smxbzllyaje

    The "timers" have two private variables "countdown" and "active".

    If active=1 - every 1000 milliseconds subtract 1 from value countdown.

    "Active" is set to 1 by clicking on an instance. (they are in containers with the text object)

    The problem however is, that when I click on the second instance its timer will count down synchronized with the first timer. It's kinda hard to explain, see the .cap and see if you can figure out what I mean. It becomes very evident if you change the "every 1000 milliseconds" to "every 5000 milliseconds", and you click the second instance 3 seconds after you click the first. The second timer will change its number at the exact same time as the first timer, not 3 seconds after the first.

    So what would be an easy way to get around this problem?

  • 'Every' events trigger without regard for specific instances, since they're a system condition. You can keep individual timers by subtracting from the instance's 'countdown' variable, which will work instance-by-instance. Note TimeDelta is the time in seconds since the last tick (the last time the event was run).

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 'Every' events trigger without regard for specific instances, since they're a system condition.

    D'oh! I didn't think about that

    Thanks for taking your time to help in the middle of your uhhhh... exam period (not sure if that's even a word in English)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[Plugin] instance bank2
85 18,373
rexrainbow's avatar
rexrainbow
Unread hot topic
0 Favourites
[PLUGIN] Instance Group
50 17,111
sagispin's avatar
sagispin
Unread hot topic
47 11,343
Rable's avatar
Rable