Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Gamma

I recently placed the debug menu on my game, and I happened to see that I had over 500 draws....very small amount of system lag, yet I feel as if I should have done something about it. Is there a way to reduce the amount of draws, or should I keep it as is?

1 decade ago by Graphikos

Draws are typically the most expensive function with Canvas2D. Although it has got considerably better over time it's still in your best interest to reduce it when you can especially if you plan on deploying to mobile devices.

Ways to reduce the amount of draws all depends on where they are coming from.

1 decade ago by Elvar

I have moved some of my interface out in the DOM, so that player status (health, gold etc.) is not drawn in Canvas, this saves alot :).

1 decade ago by amadeus

Pre-rendering backgrounds could bring draws down considerably.

1 decade ago by StuartTresadern

Take a look at the Dynamic Map Plugin http://impactjs.com/forums/code/dynamic-map-plugin the breakout clone demo shows how you can build a panel using a background map that only gets updated when you want it to. The rest of the time it will only require 1 draw call.

Make sure that all non-animated backgrounds are Pre-Rendered as amadeus pointed out. If you have animated background maps again look at the demo above this would allow you to only update the map when things change.

With the demos for the value map and the Dynamic Map I have left the debug info visible so that you can see how it reduces the number of draw calls.

1 decade ago by Gamma

I think most of my draws are coming from my repeated use of tiles for my background.

1 decade ago by StuartTresadern

If your backgrounds as set as pre render then impact will chunk the background tiles and reduce the draw calls. If you have lots of animated background tiles you will need to look at some type of cache to reduce the draws.

1 decade ago by Gamma

Thank you guys so much, it worked! Pre-rendering it made it go from 500 draws to 13, thanks guys!
Page 1 of 1
« first « previous next › last »