2017-06-30 14:47:51 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-05-02 15:02:49 +00:00
|
|
|
var EventDispatcher = require('../../events/EventDispatcher');
|
2017-06-30 14:47:51 +00:00
|
|
|
var Map = require('../../structs/Map');
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-08-01 12:10:08 +00:00
|
|
|
// Animations are managed by the global AnimationManager. This is a singleton class that is
|
|
|
|
// responsible for creating and delivering animations and their corresponding data to Game Objects.
|
|
|
|
// Sprites and other Game Objects get the data they need from the AnimationManager.
|
|
|
|
// Access it via `scene.anims`.
|
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
var AnimationManager = new Class({
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
initialize:
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
function AnimationManager (game)
|
|
|
|
{
|
|
|
|
this.game = game;
|
2017-05-02 15:02:49 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.textureManager = null;
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.events = new EventDispatcher();
|
2017-05-02 15:49:48 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.globalTimeScale = 1;
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.anims = new Map();
|
2017-04-12 12:53:55 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.paused = false;
|
|
|
|
},
|
2017-04-12 12:53:55 +00:00
|
|
|
|
|
|
|
boot: function (textureManager)
|
|
|
|
{
|
|
|
|
this.textureManager = textureManager;
|
|
|
|
},
|
|
|
|
|
2017-09-13 13:17:38 +00:00
|
|
|
add: require('./inc/AddAnimation'),
|
|
|
|
create: require('./inc/CreateFrameAnimation'),
|
|
|
|
fromJSON: require('./inc/FromJSON'),
|
|
|
|
generateFrameNames: require('./inc/GenerateFrameNames'),
|
|
|
|
generateFrameNumbers: require('./inc/GenerateFrameNumbers'),
|
|
|
|
get: require('./inc/GetAnimation'),
|
|
|
|
load: require('./inc/LoadAnimationToGameObject'),
|
|
|
|
pauseAll: require('./inc/PauseAll'),
|
|
|
|
play: require('./inc/PlayAnimation'),
|
|
|
|
remove: require('./inc/RemoveAnimation'),
|
|
|
|
resumeAll: require('./inc/ResumeAll'),
|
|
|
|
staggerPlay: require('./inc/StaggerPlayAnimation'),
|
|
|
|
toJSON: require('./inc/ToJSON'),
|
2017-04-12 12:53:55 +00:00
|
|
|
|
|
|
|
destroy: function ()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
2017-06-30 14:47:51 +00:00
|
|
|
|
|
|
|
});
|
2017-04-12 12:53:55 +00:00
|
|
|
|
|
|
|
module.exports = AnimationManager;
|