Dart Documentationsystem_animatorAnimatable

Animatable class

Component use to store a bag of Animation to play.

Because Animation are a bag of "callback" function, it doesn't follow the philosofy of EntitySystem (Component should be only primitive).

class Animatable extends ComponentPoolable {
 final l = new LinkedBag<Animation>();

 Animatable._();
 static _ctor() => new Animatable._();
 factory Animatable() {
   var c = new Poolable.of(Animatable, _ctor);
   c.cleanUp();
   return c;
 }

 void cleanUp() {
   l.clear();
 }

 /// this is a sugar method for [l].add([a])
 /// sugar because you can write
 ///
 ///    new Animatable()
 ///      ..add(new Animation())
 ///      ..add(new Animation())
 ///
 Animatable add(Animation a) {
   l.add(a);
   return this;
 }
}

Extends

Component > Component_Poolable > ComponentPoolable > Animatable

Constructors

factory Animatable() #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
factory Animatable() {
 var c = new Poolable.of(Animatable, _ctor);
 c.cleanUp();
 return c;
}

Properties

final l #

final l = new LinkedBag<Animation>()

Methods

Animatable add(Animation a) #

this is a sugar method for l.add( a) sugar because you can write

new Animatable()

 ..add(new Animation())
 ..add(new Animation())
Animatable add(Animation a) {
 l.add(a);
 return this;
}

void cleanUp() #

If you need to do some cleanup when removing this component override this method.

docs inherited from ComponentPoolable
void cleanUp() {
 l.clear();
}

void moveToPool() #

inherited from Component_Poolable

Calls the cleanup function and moves this object to the ObjectPool.

void moveToPool() {
 cleanUp();
 ObjectPool.add(this);
}