Time based animation toggle?

Get help using Construct 2

Post » Sun Jul 28, 2013 10:39 am

I see sometimes animation snubs off and toggles... meaning there could be a race condition happening.

So wondering if there is a better way to do this.. that will ensure that the timing race doesnt happen between these two animations?

"Default" has no image
"LazerON" has a lazer beam animating glow




Thanks :)
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » Sun Jul 28, 2013 1:37 pm

If you step back a minute, your code is saying:

every 5 seconds turn the laser on and every 5 seconds turn the laser off

The race condition is pretty self evident.

There's also the case where the laser goes out of range, but comes back in again within 5 seconds. You are still going to have the previous '5 second Wait to turn off' code sitting around, so if the laser is turned on again, it's going to be turned off in less than 5 seconds.


I'd recommend using the new timer object over Wait. People are constantly abusing Wait. With a Timer you can control when to stop a timer, but you can't stop a Wait (without a bunch of extra work, which Timer is doing for you).

blackhornet2013-07-28 13:54:13
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990


Return to How do I....?

Who is online

Users browsing this forum: ASHKAR, kellehk, R0J0hound, ST314 and 22 guests