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

1 decade ago by doobdargent

Hey guys,
for my current game, I'm using 2 entities pools. One for the bullets and one for the particles.
I was wondering if it was possible to merge both pools into one generic EntityPool that will manage instances of the Entity class.
To be able to do this, I need a way to transform an Entity to an EntityBullet (which extends Entity), and a way to transform an EntityBullet back to an Entity with default properties and methods.

How can I do that?

I thought of doing something like this to transform and Entity to an EntityBullet:

var entity = new ig.Entity();
entity = new EntityBullet();

But doing it like this, am I not using a pool for nothing?

Thanks for any input!

1 decade ago by dominic

Why are you using an entity pool in the first place? Is entity creation and garbage collection a performance bottleneck in your case?

Switching out entity classes is pretty difficult to get right, I believe. You'd have to fiddle with the .prototype and .constructor properties. Also, copying over all default attributes (using ig.merge() or similar) is probably not that much faster.

1 decade ago by doobdargent

Thanks for your reply dominic.

I'm doing a "Bullet Manager" because I learned that while I was programming in C. I read a few days ago that Object pools are non-sense in language where there is a garbage collector.

I admit that I didn't even try without. I'll do some benchmarks next week.

About switching Entity classes, you're right, it might not be worth it !
Page 1 of 1
« first « previous next › last »