So the ENTER_FRAME property will add an object to the stage on every frame the game runs. If the game is 24 fps, 24 objects created per second. How can I limit that so it will generate an object every 4 frames?
you can have a counter that increments every frame
var f:int = 0;
addEventListener(Event.ENTER_FRAME,onEnterFrame);
function onEnterFrame(e:Event):void{
if (f%4 == 0){
// do something
}
f++;
}
you can set f=0;
inside the if statement if you like
if(0 == ++f % 4)
Marty 2012-04-04 23:45