Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

want to know if is it possible to use single timer or scheduler method for multiple sprites ? Like I am now working on a game and there could be any number of sprites and i want to perform some actions on all of that sprites, So do I have to use as many timers or schedulers as sprites ? Or How can the job be done using only a single timer or scheduler ? What is I schedule a method and use it for, Say 10 sprites ? Will it affect the performance..?

share|improve this question

1 Answer 1

Usually you'll just create one scheduler that calls the update method of your world/game. There you iterate through all entities/sprites and call their update method.

This gives you much better control about the flow of your code. You'll be able to run the physics-simulation first and then iterate through all bodies/sprites and update their position.

Having all entities within a data-structure also gives you greater control about when/how entities will be added and removed from updates as well as better means of debugging (scheduled updates can be cumbersome to debug if you have lots of sprites).

share|improve this answer
    
@bummezack grat answer. I was looking to improve my code and was a bit stuck on this. I used entities cache handlers and within those was calling the update methods and overall my project is starting to be too complex now and there is the risk to loose control of it. Thanks :) –  mm24 Sep 3 '12 at 16:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.