Fork me on GitHub
View source

package haxepunk

class EntityList<T>


extends Entity
extended by ButtonTray, LayerList

A group of entities which can be added to or removed from the Scene and moved together. Also supports object pooling.


Available since:

2.6.0

Constructor

View source

new () : Void

Variables

read only count : Int

entities : Array<T>

Functions

View source

add (entity : T, index : Int = -1) : T

Add an Entity to this EntityList and its Scene.


Parameters:
entity   

The Entity to be added.

index   

Position to insert the Entity, default last.


Returns:

The Entity.

View source

added () : Void

View source

apply (f : T ->Void, ) : Void

Call a function on all Entities in an EntityList.

View source

clearRecycled () : Void

Clears stored reycled Entities of the Class type.

View source

create (cls : Class<T>, constructorArgs : Array<Dynamic>) : T

Returns a new Entity, or a stored recycled Entity if one exists.


Parameters:
addToScene   

Add it to the Scene immediately.

constructorArgs   

List of the entity constructor arguments (optional).


Returns:

The new Entity object.

View source

map<R> (f : T ->R, ) : Array<R>

Call a function on all Entities in an EntityList and return its value.

View source

pop () : T

View source

recycle (entity : T) : T

Removes the Entity from the EntityList at the end of the frame and recycles it. The recycled Entity can then be fetched again by calling the create() function.


Parameters:
e   

The Entity to recycle.


Returns:

The recycled Entity.

View source

remove (entity : T) : T

Remove an Entity from this EntityList and its Scene.


Parameters:
entity   

The Entity to be removed.


Returns:

The Entity.

View source

removed () : Void