A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: performance: create bitmap vs sprite

  1. #1
    Senior Member fantasio's Avatar
    Join Date
    May 2000
    Location
    at the progress bar
    Posts
    409

    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!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  3. #3
    Member
    Join Date
    Aug 2010
    Posts
    65
    Quote Originally Posted by 5TonsOfFlax View Post
    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

  4. #4
    Senior Member fantasio's Avatar
    Join Date
    May 2000
    Location
    at the progress bar
    Posts
    409
    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!

  5. #5
    Member
    Join Date
    Aug 2010
    Posts
    65
    Quote Originally Posted by fantasio View Post
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center