Impact

Defined in Module impact.entity-pool, inherits from ig.Class

Synopsis

EntityBullet = ig.Entity.extend({
	// ...
});

// Enable Pooling for this Entity Class!
ig.EntityPool.enableFor( EntityBullet );

Description

ig.EntityPool allows you to easily enable pooling for frequently used types of Entities. The EntityPool is global, you don't have to create it, but just enable it for your Entities.

When reviving an Entity from the Pool, Impact will call the Entity's .reset() method, instead of init().

Read more in the Entity Pooling Article.

Functions

.enableFor( EntityClass )

Augments the given EntityClass with pooling functionality. This should only be called once for each Entity Class for which you want to enable pooling.

.drainPool( classId )

Removes all Entities with the given .classId from the Pool.

Example:

ig.EntityPool.drainPool( EntityBullet.classId );

.drainAllPools()

Removes all Entities from the Pool.

This function is automatically called by the Game's .loadLevel() method, before the new level is loaded.