Thomas Blommaert
Thomas Blommaert

Reputation: 67

Tween large bitmap without lag

I'm using a 3800x3000 bitmap as a background of a game.

Now, I first show the whole bitmap - the landscape -, and than zoom in at the characters. I'm using TweenMax from GreenSock, but even with this advanced tween class my bitmap doesn't move and scale smooth.

Any ideas how to solve this? I'd like to work with smaller bitmaps too and scale them, but than I'll lose the quality, and I can't blur the bitmap to hide the quality loss, since there's a terrain in the bitmap too, and I don't want to blur that.

Upvotes: 0

Views: 1310

Answers (2)

Jonathan Dunlap
Jonathan Dunlap

Reputation: 2631

This really isn't a Flash specific problem as it's more of a general game development question in nature. Manipulating a huge basic bitmap (in any language) in memory is going to be slow no matter what. You're essentially moving hundreds of megabytes of memory into the current frame buffer on every draw call. If you look at most huge background games like side-scrollers, the background is composed of many small objects replicated hundred of times. This technique is then combined with only putting the small sprites that can be seen in the current screen buffer onto the stage. When moving around the map, you remove the pieces that are not being seen anymore and more tiles where the screen is moving to. This part of the technique is often called tile buffering. Hope this helps!

Upvotes: 1

Ross Smith
Ross Smith

Reputation: 755

Why is the bitmap so large? Does your target device / screen extend to 3800x3000?

Suggestions:

  1. Sidestep the problem. Use a smaller bitmap, or break it into several small bitmaps, or reproduce more of the background with vector shapes. Obviously not every piece of art can be recreated as vector, but if you can you will get huge file size savings and some performance improvement.

  2. Make sure cacheAsBitmap is enabled. This tells Flash to optimize the rendering of bitmaps. It works best when the bitmaps have no filters, few transforms, and do not move or rotate often. It's ideal for unmoving backdrops.

  3. HARD MODE: If you want to get extremely fancy and your target audience supports the latest Flash Player, try creating your backdrop as a texture for a rectangle in the 3D space that exists behind the 2D stage. See this post by Thibault Imbert for an idea of what I mean: http://www.bytearray.org/?p=2555

Upvotes: 1

Related Questions