mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Adding docs.
This commit is contained in:
+57
-17
@@ -1,18 +1,44 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.TweenManager
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Phaser - TweenManager
|
||||
*
|
||||
*
|
||||
* @class Phaser.TweenManager
|
||||
* @classdesc
|
||||
* Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated.
|
||||
* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
|
||||
*
|
||||
* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
|
||||
* TweenManager is based heavily on tween.js by {@link http://soledadpenades.com|sole}.
|
||||
* The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object.
|
||||
* It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors.
|
||||
* Please see https://github.com/sole/tween.js for a full list of contributors.
|
||||
* Please see {@link https://github.com/sole/tween.js} for a full list of contributors.
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.TweenManager = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {array} _tweens - Description.
|
||||
* @private
|
||||
*/
|
||||
this._tweens = [];
|
||||
|
||||
/**
|
||||
* @property {array} _add - Description.
|
||||
* @private
|
||||
*/
|
||||
this._add = [];
|
||||
|
||||
this.game.onPause.add(this.pauseAll, this);
|
||||
@@ -22,11 +48,17 @@ Phaser.TweenManager = function (game) {
|
||||
|
||||
Phaser.TweenManager.prototype = {
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {string} REVISION
|
||||
* @default
|
||||
*/
|
||||
REVISION: '11dev',
|
||||
|
||||
/**
|
||||
* Get all the tween objects in an array.
|
||||
* @return {Phaser.Tween[]} Array with all tween objects.
|
||||
* @method getAll
|
||||
* @returns {Phaser.Tween[]} Array with all tween objects.
|
||||
*/
|
||||
getAll: function () {
|
||||
|
||||
@@ -36,19 +68,20 @@ Phaser.TweenManager.prototype = {
|
||||
|
||||
/**
|
||||
* Remove all tween objects.
|
||||
* @method removeAll
|
||||
*/
|
||||
removeAll: function () {
|
||||
|
||||
this._add.length = 0;
|
||||
this._tweens.length = 0;
|
||||
this._tweens = [];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new tween into the TweenManager.
|
||||
*
|
||||
* @param tween {Phaser.Tween} The tween object you want to add.
|
||||
* @return {Phaser.Tween} The tween object you added to the manager.
|
||||
* @method add
|
||||
* @param {Phaser.Tween} tween - The tween object you want to add.
|
||||
* @returns {Phaser.Tween} The tween object you added to the manager.
|
||||
*/
|
||||
add: function ( tween ) {
|
||||
|
||||
@@ -57,11 +90,12 @@ Phaser.TweenManager.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @param obj {object} Object the tween will be run on.
|
||||
* @return {Phaser.Tween} The newly created tween object.
|
||||
*/
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @method create
|
||||
* @param {Object} object - Object the tween will be run on.
|
||||
* @returns {Phaser.Tween} The newly created tween object.
|
||||
*/
|
||||
create: function (object) {
|
||||
|
||||
return new Phaser.Tween(object, this.game);
|
||||
@@ -71,7 +105,8 @@ Phaser.TweenManager.prototype = {
|
||||
/**
|
||||
* Remove a tween from this manager.
|
||||
*
|
||||
* @param tween {Phaser.Tween} The tween object you want to remove.
|
||||
* @method remove
|
||||
* @param {Phaser.Tween} tween - The tween object you want to remove.
|
||||
*/
|
||||
remove: function ( tween ) {
|
||||
|
||||
@@ -88,7 +123,8 @@ Phaser.TweenManager.prototype = {
|
||||
/**
|
||||
* Update all the tween objects you added to this manager.
|
||||
*
|
||||
* @return {bool} Return false if there's no tween to update, otherwise return true.
|
||||
* @method update
|
||||
* @returns {bool} Return false if there's no tween to update, otherwise return true.
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
@@ -126,8 +162,10 @@ Phaser.TweenManager.prototype = {
|
||||
|
||||
/**
|
||||
* Pauses all currently running tweens.
|
||||
*
|
||||
* @method update
|
||||
*/
|
||||
pauseAll: function () {
|
||||
pauseAll: function () {
|
||||
|
||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||
this._tweens[i].pause();
|
||||
@@ -137,8 +175,10 @@ Phaser.TweenManager.prototype = {
|
||||
|
||||
/**
|
||||
* Pauses all currently paused tweens.
|
||||
*
|
||||
* @method resumeAll
|
||||
*/
|
||||
resumeAll: function () {
|
||||
resumeAll: function () {
|
||||
|
||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||
this._tweens[i].resume();
|
||||
|
||||
Reference in New Issue
Block a user