Phaser.TweenManager = function (game){ this.game = game; this._tweens = [] ; this._add = [] ; this.easeMap = { "Power0": Phaser.Easing.Power0, "Power1": Phaser.Easing.Power1, "Power2": Phaser.Easing.Power2, "Power3": Phaser.Easing.Power3, "Power4": Phaser.Easing.Power4, "Linear": Phaser.Easing.Linear.None, "Quad": Phaser.Easing.Quadratic.Out, "Cubic": Phaser.Easing.Cubic.Out, "Quart": Phaser.Easing.Quartic.Out, "Quint": Phaser.Easing.Quintic.Out, "Sine": Phaser.Easing.Sinusoidal.Out, "Expo": Phaser.Easing.Exponential.Out, "Circ": Phaser.Easing.Circular.Out, "Elastic": Phaser.Easing.Elastic.Out, "Back": Phaser.Easing.Back.Out, "Bounce": Phaser.Easing.Bounce.Out, "Quad.easeIn": Phaser.Easing.Quadratic.In, "Cubic.easeIn": Phaser.Easing.Cubic.In, "Quart.easeIn": Phaser.Easing.Quartic.In, "Quint.easeIn": Phaser.Easing.Quintic.In, "Sine.easeIn": Phaser.Easing.Sinusoidal.In, "Expo.easeIn": Phaser.Easing.Exponential.In, "Circ.easeIn": Phaser.Easing.Circular.In, "Elastic.easeIn": Phaser.Easing.Elastic.In, "Back.easeIn": Phaser.Easing.Back.In, "Bounce.easeIn": Phaser.Easing.Bounce.In, "Quad.easeOut": Phaser.Easing.Quadratic.Out, "Cubic.easeOut": Phaser.Easing.Cubic.Out, "Quart.easeOut": Phaser.Easing.Quartic.Out, "Quint.easeOut": Phaser.Easing.Quintic.Out, "Sine.easeOut": Phaser.Easing.Sinusoidal.Out, "Expo.easeOut": Phaser.Easing.Exponential.Out, "Circ.easeOut": Phaser.Easing.Circular.Out, "Elastic.easeOut": Phaser.Easing.Elastic.Out, "Back.easeOut": Phaser.Easing.Back.Out, "Bounce.easeOut": Phaser.Easing.Bounce.Out, "Quad.easeInOut": Phaser.Easing.Quadratic.InOut, "Cubic.easeInOut": Phaser.Easing.Cubic.InOut, "Quart.easeInOut": Phaser.Easing.Quartic.InOut, "Quint.easeInOut": Phaser.Easing.Quintic.InOut, "Sine.easeInOut": Phaser.Easing.Sinusoidal.InOut, "Expo.easeInOut": Phaser.Easing.Exponential.InOut, "Circ.easeInOut": Phaser.Easing.Circular.InOut, "Elastic.easeInOut": Phaser.Easing.Elastic.InOut, "Back.easeInOut": Phaser.Easing.Back.InOut, "Bounce.easeInOut": Phaser.Easing.Bounce.InOut} ; this.game.onPause.add(this._pauseAll, this); this.game.onResume.add(this._resumeAll, this); } ; Phaser.TweenManager.prototype = { getAll: function (){ return this._tweens; } , removeAll: function (){ for (var i = 0; i < _AN_Read_length("length", this._tweens); i++ ){ this._tweens[i].pendingDelete = true ; } this._add = [] ; } , removeFrom: function (obj, children){ if (typeof children === 'undefined') { children = true ; } var i; var len; if (Array.isArray(obj)) { for (i = 0, len = _AN_Read_length('length', obj); i < len; i++ ){ this.removeFrom(obj[i]); } } else if (obj.type === Phaser.GROUP && children) { for (var i = 0, len = _AN_Read_length('length', obj.children); i < len; i++ ){ this.removeFrom(obj.children[i]); } } else { for (i = 0, len = _AN_Read_length('length', this._tweens); i < len; i++ ){ if (obj === _AN_Read_target('target', this._tweens[i])) { this.remove(this._tweens[i]); } } for (i = 0, len = _AN_Read_length('length', this._add); i < len; i++ ){ if (obj === _AN_Read_target('target', this._add[i])) { this.remove(this._add[i]); } } } } , add: function (tween){ tween._manager = this; this._add.push(tween); } , create: function (object){ return new Phaser.Tween(object, this.game, this); } , remove: function (tween){ var i = this._tweens.indexOf(tween); if (i !== -1) { this._tweens[i].pendingDelete = true ; } else { i = this._add.indexOf(tween); if (i !== -1) { this._add[i].pendingDelete = true ; } } } , update: function (){ var addTweens = _AN_Read_length('length', this._add); var numTweens = _AN_Read_length('length', this._tweens); if (numTweens === 0 && addTweens === 0) { return false ; } var i = 0; while (i < numTweens){ if (this._tweens[i].update(this.game.time.time)) { i++ ; } else { this._tweens.splice(i, 1); numTweens-- ; } } if (addTweens > 0) { this._tweens = this._tweens.concat(this._add); this._add.length = 0; } return true ; } , isTweening: function (object){ return this._tweens.some(function (tween){ return _AN_Read_target('target', tween) === object; } ); } , _pauseAll: function (){ for (var i = _AN_Read_length('length', this._tweens) - 1; i >= 0; i-- ){ this._tweens[i]._pause(); } } , _resumeAll: function (){ for (var i = _AN_Read_length('length', this._tweens) - 1; i >= 0; i-- ){ this._tweens[i]._resume(); } } , pauseAll: function (){ for (var i = _AN_Read_length('length', this._tweens) - 1; i >= 0; i-- ){ this._tweens[i].pause(); } } , resumeAll: function (){ for (var i = _AN_Read_length('length', this._tweens) - 1; i >= 0; i-- ){ this._tweens[i].resume(true ); } } } ; Phaser.TweenManager.prototype.constructor = Phaser.TweenManager;