Rotating Multiple Instances Of Same Object Continuously

Hello,

I would like to Rotate multiple instances of same object continuously. 

Here is the code I’ve written in enterFrame event.

    for i=#objects,1, -1 do         if(objects[i] and objects[i].x) then             objects[i].rotation = objects[i].rotation+25         end         end

My game is a multiscreen game. there are around 15-20 instances of the object that I am trying to rotate in enterFrame event. But at a time, there will be only 3-4 instances visible on screen. All other instances will be offscreen.

The above code works, but sometimes it does not rotate all the objects as enterFrame executes so quickly (around 55-60 FPS). So can anyone please suggest a better solution?

Depending upon your framerate (30 or 60), your object will be rotating by 25 degrees every 1/30th or 1/60th of a second; i.e every 0.0333 or 0.0166 secs.

If you want to use enterFrame you’ll need to calculate how many degrees you actually want to rotate very tick.

It might be better to use a timer or build your own implementation.

Depending upon your framerate (30 or 60), your object will be rotating by 25 degrees every 1/30th or 1/60th of a second; i.e every 0.0333 or 0.0166 secs.

If you want to use enterFrame you’ll need to calculate how many degrees you actually want to rotate very tick.

It might be better to use a timer or build your own implementation.