-
Senior Member
performance: create bitmap vs sprite
hi there,
in my current project i need to make some performance optimizations.
i was wondering if it is faster to draw a background with
Code:
var bg =new Sprite()
bg.graphics.clear()
bg.graphics.beginFill(0xff0000)
bg.graphics.drawRect(0,0,w,h)
bg.graphics.endFill();
or do the
Code:
var bg =new Bitmap(new BitmapData(w,h,false,0)
?
there are a lot of moving objects on top of "bg"
thanks!
-
Test it. But either way, drawing a background should only happen once. Even if one is 10 times slower than the other, it should not have much effect.
If you do use the Sprite way, you may want to set cacheAsBitmap to true so that it does not have to re-render.
-
Originally Posted by 5TonsOfFlax
Test it. But either way, drawing a background should only happen once. Even if one is 10 times slower than the other, it should not have much effect.
not necessarily, one might want to redraw the backround when scrolling for example.
i would go for bitmapdata and copypixels, those are the fastest generally
-
Senior Member
i tested a little bit, and it seems that the sprite yields a better performance than the bitmap...
i was always under the impression that bitmaps would perform better.
the project i took over from a different developer is a game with some huge (8000 px wide and more ) movieclips in a parallax scroller.
even though there is a mask in place, the performance is less than stellar.
i guess i should actually snip these big clips in small ones an spawn them when needed,
however there is not a lot of time for this kind of solution.
testing, one two it is...
any input welcome, thanks!
-
Originally Posted by fantasio
i tested a little bit, and it seems that the sprite yields a better performance than the bitmap...
i was always under the impression that bitmaps would perform better.
the project i took over from a different developer is a game with some huge (8000 px wide and more ) movieclips in a parallax scroller.
even though there is a mask in place, the performance is less than stellar.
i guess i should actually snip these big clips in small ones an spawn them when needed,
however there is not a lot of time for this kind of solution.
testing, one two it is...
any input welcome, thanks!
the biggest slow down in movieclips or sprites comes from having to redraw vector graphics each frame, however if you dont need to, or using cacheasbitmap(uses more memory) it may be faster.
Yes slicing to smaller pieces will definitely help for vector graphics!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|