|
Gotcha, my suggestion, might require too much change to be worthwhile, but won't hurt to say it. Here is the assumptions I am working off of: - You have a background layer, lets just say it's a blue background
- A middle layer, lets say clouds that move as you move to the right
- And a tile layer, which draws the sprites, and the tiles of the maps For the tile layer, we can break it down into two separate groups, animated sprites, and static sprites. The static sprites, can be drawn to the offscreen canvas, and you get the imageData from that one time, and then push that data to the screen there after. Then the animated sprites will just be drawn to the on screen canvas every time. http://imgur.com/n6RFF The stuff that should be drawn to the offscreen canvas, then grab the image data has gray around it, and the animated sprites are in the green. So for drawing the tiles of the map we only have to loop through the tile data, one time, and after that if the imgData remains valid (a separate flag) we can just push that imgData to the screen. This would also allow drawing section of the screens on the offscreen canvas in chunks, and storing that draw to just be pushed to the screen at appropriate times. I don't know if I explained it very well, I could probably through together a crappy little demo if you'd like. |