0
votes

I have two options and i want to know whats faster

I have a pool of 1000 sprites objects in as3 on screen

when its needed each sprite has to resize itself

I can

1 - make each sprite a simple container to use graphics to draw a rectangle, that is, call a 'spriteInstance.graphics.' ,draw the rectangle and on each 'refresh', I do graphics.clear and redraw the rectangle but with the new size, this for each sprite.

or

2 - create each sprite with a border and on each refresh, resize it

whats better?

1

1 Answers

2
votes

Well, either way, you're creating a sprite for each rectangle, and what you've described is essentially the same thing so I doubt there will be any major performance enhancement there.

However, I believe that you could increase your performance by just having one sprite, holding the data of each 'sprite' in a vector, and then iterating through that vector, drawing each rectangle in the one sprite.

You might also want to look at bitmap blitting (if you wanna keep each sprite individually) and double buffering for extra performance boost.