Should we pool objects in games?

0 favourites
  • 6 posts
From the Asset Store
Enjoy the powerful simulation with accurate ball physics, build with realistic ball spinning animations
  • I read Ashley's really good article at m.netmagazine.com/tutorials/make-your-javascript-apps-smoother . He suggested avoiding creating objects too often in Javascript.

    My question is, at a higher level, in Construct2, should we also be avoiding creating/destroying too many sprites on the fly and instead have a "pool" of them that we can re-use?

    A good example are bullets, which get created and destroyed very often.

    Obviously the answer might be "depends", I just wanted to make sure there is nothing in the Construct2 engine already doing the "pooling" of sprites and objects for us.

    Thanks!

  • I believe C2 already does the pooling for you, and that's how Ashley managed to improve the performances of the engine over the releases.

    Creating a lot of objects at once every tick will take a hit on performances though, but managing a pool of objects to reuse seems like overkill for, I believe, C2 already handles it at runtime.

  • Kyatric sounds correct here - I noticed this little performance bonus the other day where I have a sprite that explodes and creates lots of little shrapnel pieces, each one a little 6x6 sprite. The first time it runs the browser drops pretty heavily in FPS for half a second. But after that, despite having destroyed the sprites and creating them again in C2, I no longer get the frame-drop of creating them. I was considering adding in a pre-cache step on layout start that generates a bunch of sprites that I know I will need, like my shrapnel sprites, but I wasn't sure if this was a good idea or not.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Kyatric, I found this topic searching for "pool" since I was wondering if I needed to do this or if construct already did. Now, you don't sound 100% sure that construct does this. Could you confirm? Or maybe Ashley can confirm?

    Thanks.

  • MakubeX: Since this old thread (jan 2012) Ashley wrote a blog article about how he handled garbage collection in JS/C2.

    So yes it is confirmed that C2 does recycle objects and as far as performances go everything you need to care about is gathered in the performance tips manual article and you can also check this, and that blog articles for a little more insight.

  • Thanks for clarifying, KYATRIC.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)