individual timer on instances

For questions about using Classic.

Post » Tue May 06, 2008 7:22 pm

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?
B
3
G
4
Posts: 28
Reputation: 1,133

Post » Tue May 06, 2008 7:38 pm

'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).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Tue May 06, 2008 8:23 pm

[quote="Ashley":3hx6p5yk]'Every' events trigger without regard for specific instances, since they're a system condition.[/quote:3hx6p5yk]

D'oh! I didn't think about that :oops:

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)
B
3
G
4
Posts: 28
Reputation: 1,133


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest