In the game I'm developing, I have a flamethrower as a weapon. I want to make the flames die after 5 seconds but the way ImpactJS is made, setTimeout isn't working for me. Anyone have any ideas of how to fire functions after an allotted amount of time?
1 decade ago
by nefD
Check out ig.Timer:
http://impactjs.com/documentation/class-reference/timer
Basically, you could create one, and call it's delta() method to get the number of seconds (in game time) since it's creation. So, for example, you could do something like:
if ( this.flameTimer.delta() >= 5 ) // 5 seconds has passed
At which point, you could set flameTimer to false, or set some other property which represents the fact that you can shoot again.
1 decade ago
by MikeL
I have a somewhat similar example in the
YOSS game. In that case the playerShip entity can only fire 3 times before it has to "reload". There is a reload delay of 0.4 seconds.
Have a look at the code and search for "reloadTimer".
Thanks! I appreciate the speedy and thorough responses :)
Page 1 of 1
« first
« previous
next ›
last »