IgeAnimationComponent

Method: start

Starts an animation from the beginning frame.
start (String animId, Object options)
  • StringanimId The id of the animation to start.
  • Objectoptions An object with some option properties.
Returns *

Start an animation

// Create an entity, add the animation component, define
// an animation and then start it
var entity = new IgeEntity()
    .addComponent(IgeAnimationComponent)
    .animation.define('anim1', [1, 2, 3, 4], 25, -1);

entity.animation.start('anim1');

Start an animation with callbacks for animation events

// Create an entity, add the animation component, define
// an animation and then start it
var entity = new IgeEntity()
    .addComponent(IgeAnimationComponent)
    .animation.define('anim1', [1, 2, 3, 4], 25, -1);

// In each animation callback...
// this = the entity's animation component instance
// anim = the animation component's _anim object
// this._entity = the entity the animation is attached to

entity.animation.start('anim1', {
        onLoop: function (anim) {
            console.log('Animation looped', this, anim);    
        },
        onStopped: function (anim) {
            console.log('Animation stopped', this, anim);   
        },
        onComplete: function (anim) {
            console.log('Animation completed', this, anim); 
        }
});

Start an animation with callbacks for animation events via event listeners

// Create an entity, add the animation component, define
// an animation and then start it
var entity = new IgeEntity()
    .addComponent(IgeAnimationComponent)
    .animation.define('anim1', [1, 2, 3, 4], 25, -1);

// In each animation callback...
// this = the entity's animation component instance
// anim = the animation component's _anim object
// this._entity = the entity the animation is attached to

entity.animation.on('started', function (anim) {
        console.log('Animation started', this, anim);   
});

entity.animation.on('loopComplete', function (anim) {
        console.log('Animation looped', this, anim);    
});

entity.animation.on('stopped', function (anim) {
        console.log('Animation stopped', this, anim);   
});

entity.animation.on('complete', function (anim) {
        console.log('Animation complete', this, anim);  
});

entity.animation.start('anim1');
© Copyright 2013 Irrelon Software Limited. All Rights Reserved. UK Registered Company Number: 07522767
Isogenic (ī´sōjen´ik): Adj originating from a common source; possessing the same genetic composition.
Strange Things Happen at the One Two Point