I’ve read around that CopyPixels is hinted to be one of the fastest ways of rendering a tilebased map. So I thought I’d might as well try it out.
Right now, I have a 30X30 isometric tiled map, each tile is 70pixels in width and 30 pixels in length. My screensize is 960X400. - So at any point, there is around 13X13 tiles on the screen.
The thing is, I have 4 layers of tiles which Flash has to iterate through to attach them onto the stage.
Currently, I’m just attaching a movieclip of each tile onto the stage. Flash runs through a loop to put everything into one movieclip. Then I set my container movieclip’s “cacheAsBitmap” to true.
This runs at a smooth 25fps, including scrolling.
Now I when I try it out with CopyPixels, the FPS rate is much lower. Perhaps I’m not correctly using it?
Here’s how I’ve done it so far.
First I create and attach a 960X400 bitmap onto the screen to fill the screen, this will become my bitmap canvas.
I have an OnEnterFrame which calls my “reRender” function everytime the stage is scrolled.
On every frame my “reRender” function ,
First clears the bitmap with a plain white “fillRect”.
Then it runs through my 4 Arrays which are 30X30 each, and it uses copyPixel() to paste the correct tile in the correct place.
Is this the correct way of using copypixels? Because using this method, brings my computer to a staggering 6-10FPS. While a simple cacheAsBitmap achieves a breezy 25FPS.
I’ve seen people create huge maps with CopyPixels with no noticable lag at all.
How do they do it?