Archive for the ‘cacheAsBitmap’ Category

Bitmap Parallax Techniques

Wednesday, December 20th, 2006

OK so it’s go go GO on this huuuuge platform game – 9 levels and a 1st March deadline. Yes, Christmas is cancelled. So I suspect that I may go a little quiet on the blog for a bit…

But… I thought you may like to know, I’ve been doing a little test on the best way to do parallax scrolling. What I wanted to avoid is having assets that come off the edges of the screen. If you make a parallax tile that’s one screenwidth, you pretty much always have to have two copies of it on screen because the join will always have to be in the middle of the screen somewhere.

So what I thought I’d try is convert the parallax layers into bitmaps, and then do bitmap fills for each one. The bitmap fill is the size of the screen, and the beauty of this method is that the tiles automatically repeat, because you can do that with bitmap fills.

So having got that working, sadly it seems that the original way is faster, assuming you cacheAsBitmap the layers. Ho hum.

Examples are here :

Using bitmapFill()

Using big tiles that go off the edge of the screen

The number in the top left hand corner is the number of ms per frame (average over 100 frames).

Now I’m going to try drawing the layers into a single bitmap instead. Wish me luck!

Artwork by Plug-in’s creative genius Dominic Minns, if you wanna see the (old) Christmas game that these assets are from : Red Nose Racer

A cacheAsBitmap vs superCacheAsBitmap demo

Saturday, November 4th, 2006

Here’s another demo of the work we’ve been doing on a custom cacheAsBitmap utility, we’re calling superCacheAsBitmap.

The circle in the middle of the demo is made up of 1000 transparent lines, so you shouldn’t be surprised that it’s very slow to render using traditional methods! Click Move Clip to get things started, and you’ll see what I mean.

Select the cacheAsBitmap option and it’s speeds up! Yay! But now hit the Rotate Clip button, and we’re back down to a grind. This is because the MovieClip’s appearance changes and the Flash Player has to re-render the clip every frame.

So now select the superCacheAsBitmap, and we’re back up to speed! We’re creating a bitmap and rotating that instead. You’ll see though that the quality isn’t very good, but often when we’re moving things at speed this isn’t a problem. But if it is, just select superCacheAsBitmap with smoothing and this time the player rotates the bitmap with interpolation. It’s slower but not as slow as without caching.

Code coming as soon as I package it up!

New improved cacheAsBitmap!

Thursday, October 26th, 2006

I’ve been working on a smart function that can convert a MovieClip into a bitmap so that it renders faster. “What’s wrong with the cacheAsBitmap property?” I hear you cry. Well much as it’s an amazing way to optimize the speed of moving clips, it can sometimes actually slow down render time!

It’s fine as long as you don’t resize or rotate your MovieClip. But as soon as you change the clip, the FlashPlayer has to re-create the bitmap cache.

So what I’ve done is make a bitmap and rotate and scale that instead. It’s not quite as good quality as when you do it with Vector graphics, but it’s so much faster it doesn’t matter.

And here’s an example:

And yes it is AS2! :-)

So I spent ages working on this code (matrix hell that you don’t want to know about), and I have a horrible feeling someone else beat me to it, so if anyone’s seen anything like this before let me know!

And I’ll be releasing this under a creative commons licence as soon as I get a spare moment, so keep an eye out :-) .

Bad Behavior has blocked 793 access attempts in the last 7 days.