Animator Getting Started API

The installation process is explained in the README.

After setup, you can use this plugin:

// Global animator manager
Fatina.plugin.animatorManager;

// Global tick manager to be able to pause / resume group of objects
Fatina.plugin.tickerManager;

// Add a Animator component to any object
Fatina.plugin.animatorManager.addAnimatorTo(object);


Import & Initialize

// require fatina
let fatina = require('fatina').default;
let fatinaAnimator = require('fatina-plugin-animator');

// initialize fatina
fatina.init();
fatina.loadPlugin(fatinaAnimator.get());


Register a shared animation

fatina.plugin.animatorManager.register('move', (obj: any, params: any) => {
    return Fatina.tween(obj.position, ['x']).setRelative(true).to({ x: params }, 500);
}, 'newTicker');


Play Animation

// let's create a phaser sprite
var test = new Phaser.Sprite(this.game, 2, 80, 'hudBg');

// add a component animator to that sprite and add 2 animations
fatina.plugin.animatorManager.addAnimatorTo(test)
    .addAnimation('moveRight', 'move', { group: 'move' }, 5)
	.addAnimation('moveLeft', 'move', { group: 'move' }, -5);

// now you can use those animation easily
test.animator.play('moveLeft');
test.animator.play('moveRight');