Jump to content

How can I duplicate a temporary sprite, or animation?


hollowdoor
 Share

Recommended Posts

I have a plan to use the same image on temporary sprites for event animations.

 

I'm wondering if there is a way to use the the same sprite at different locations, but have more than one on the screen at a time.

 

Would I have to add multiple sprites just to get a few of the same image, and animation?

 

Or maybe there's a better way, and there's something I'm missing in the documentation?

 

An example of an effect that would use this is an explosion animation on multiple objects on the screen just using the same image, and frames. It would all be at different starts in time for each animation.

Link to comment
Share on other sites

I think I have a solution.

 

I can use a queue with a set lower limit. Let's say 5-10 sprites are always in the queue, but almost always dead. Maybe a Phaser group would work for this.

 

The sprites in the queue are revived when needed.

 

When more than the limit is reached make a few more sprites. When the sprites over the limit are done animating destroy them, and remove them from the queue.

 

I know it could be premature optimization, but I foresee many possible creations of the same sprite. Probably approaching 20 within a second's time with animations , but with resting periods where none of these sprites are needed.

 

Can some body let me know if you think this is an OK solution.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...