mirror of
https://github.com/wassname/phaser.git
synced 2026-09-11 12:31:29 +08:00
Preparing more documentation.
This commit is contained in:
+16
-36
@@ -2,7 +2,6 @@
|
||||
* @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.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -118,7 +117,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Plays this animation.
|
||||
*
|
||||
* @method play
|
||||
* @method Phaser.Animation#play
|
||||
* @memberof Phaser.Animation
|
||||
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {boolean} [loop=null] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
@@ -161,7 +160,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Sets this animation back to the first frame and restarts the animation.
|
||||
*
|
||||
* @method restart
|
||||
* @method Phaser.Animation#restart
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
restart: function () {
|
||||
@@ -181,7 +180,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.
|
||||
*
|
||||
* @method stop
|
||||
* @method Phaser.Animation#stop
|
||||
* @memberof Phaser.Animation
|
||||
* @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation.
|
||||
*/
|
||||
@@ -202,7 +201,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Updates this animation. Called automatically by the AnimationManager.
|
||||
*
|
||||
* @method update
|
||||
* @method Phaser.Animation#update
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
update: function () {
|
||||
@@ -269,7 +268,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Cleans up this animation ready for deletion. Nulls all values and references.
|
||||
*
|
||||
* @method destroy
|
||||
* @method Phaser.Animation#destroy
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
destroy: function () {
|
||||
@@ -286,7 +285,7 @@ Phaser.Animation.prototype = {
|
||||
/**
|
||||
* Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.
|
||||
*
|
||||
* @method onComplete
|
||||
* @method Phaser.Animation#onComplete
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
onComplete: function () {
|
||||
@@ -304,17 +303,9 @@ Phaser.Animation.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the paused state of the Animation.
|
||||
* @memberof Phaser.Animation
|
||||
* @param {boolean} value - Set to true to pause the animation or false to resume it if previous paused.
|
||||
*
|
||||
*//**
|
||||
*
|
||||
* Returns the paused state of the Animation.
|
||||
* @memberof Phaser.Animation
|
||||
* @returns {boolean}
|
||||
*
|
||||
*/
|
||||
* @name Phaser.Animation#paused
|
||||
* @property {boolean} paused - Gets and sets the paused state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, "paused", {
|
||||
|
||||
get: function () {
|
||||
@@ -346,11 +337,9 @@ Object.defineProperty(Phaser.Animation.prototype, "paused", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the total number of frames in this Animation.
|
||||
* @memberof Phaser.Animation
|
||||
* @return {number}
|
||||
*
|
||||
*/
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
|
||||
|
||||
get: function () {
|
||||
@@ -360,17 +349,9 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets the current frame to the given frame index and updates the texture cache.
|
||||
* @memberof Phaser.Animation
|
||||
* @param {number} value - The frame to display
|
||||
*
|
||||
*//**
|
||||
*
|
||||
* Returns the current frame, or if not set the index of the most recent frame.
|
||||
* @memberof Phaser.Animation
|
||||
* @returns {Animation.Frame}
|
||||
*
|
||||
*/
|
||||
* @name Phaser.Animation#frame
|
||||
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, "frame", {
|
||||
|
||||
get: function () {
|
||||
@@ -405,8 +386,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
|
||||
* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large'
|
||||
* You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4);
|
||||
*
|
||||
* @method generateFrameNames
|
||||
* @memberof Phaser.Animation
|
||||
* @method Phaser.Animation.generateFrameNames
|
||||
* @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'.
|
||||
* @param {number} min - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the min is 1.
|
||||
* @param {number} max - The number to count up to. If your frames are named 'explosion_0001' to 'explosion_0034' the max is 34.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -64,8 +63,7 @@ Phaser.AnimationManager.prototype = {
|
||||
* Loads FrameData into the internal temporary vars and resets the frame index to zero.
|
||||
* This is called automatically when a new Sprite is created.
|
||||
*
|
||||
* @method loadFrameData
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#loadFrameData
|
||||
* @private
|
||||
* @param {Phaser.Animation.FrameData} frameData - The FrameData set to load.
|
||||
*/
|
||||
@@ -80,12 +78,11 @@ Phaser.AnimationManager.prototype = {
|
||||
* Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
|
||||
* Animations added in this way are played back with the play function.
|
||||
*
|
||||
* @method add
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#add
|
||||
* @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".
|
||||
* @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.
|
||||
* @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second.
|
||||
* @param {boolean} [loop=false] {boolean} - Whether or not the animation is looped or just plays once.
|
||||
* @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings?
|
||||
* @return {Phaser.Animation} The Animation object that was created.
|
||||
*/
|
||||
@@ -126,8 +123,7 @@ Phaser.AnimationManager.prototype = {
|
||||
/**
|
||||
* Check whether the frames in the given array are valid and exist.
|
||||
*
|
||||
* @method validateFrames
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#validateFrames
|
||||
* @param {Array} frames - An array of frames to be validated.
|
||||
* @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false)
|
||||
* @return {boolean} True if all given Frames are valid, otherwise false.
|
||||
@@ -162,8 +158,7 @@ Phaser.AnimationManager.prototype = {
|
||||
* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
|
||||
* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
|
||||
*
|
||||
* @method play
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#play
|
||||
* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
|
||||
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {boolean} [loop=null] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
@@ -193,8 +188,7 @@ Phaser.AnimationManager.prototype = {
|
||||
* Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped.
|
||||
* The currentAnim property of the AnimationManager is automatically set to the animation given.
|
||||
*
|
||||
* @method stop
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#stop
|
||||
* @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.
|
||||
* @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)
|
||||
*/
|
||||
@@ -223,8 +217,7 @@ Phaser.AnimationManager.prototype = {
|
||||
/**
|
||||
* The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.
|
||||
*
|
||||
* @method update
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#update
|
||||
* @protected
|
||||
* @return {boolean} True if a new animation frame has been set, otherwise false.
|
||||
*/
|
||||
@@ -249,8 +242,7 @@ Phaser.AnimationManager.prototype = {
|
||||
/**
|
||||
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
|
||||
*
|
||||
* @method destroy
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @method Phaser.AnimationManager#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
@@ -265,8 +257,8 @@ Phaser.AnimationManager.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @return {Phaser.Animation.FrameData} Returns the FrameData of the current animation.
|
||||
* @name Phaser.AnimationManager#frameData
|
||||
* @property {Phaser.Animation.FrameData} frameData - The current animations FrameData.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
|
||||
|
||||
@@ -277,8 +269,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @return {number} Returns the total number of frames in the loaded FrameData, or -1 if no FrameData is loaded.
|
||||
* @name Phaser.AnimationManager#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
||||
|
||||
@@ -297,11 +289,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @return {boolean} Returns the paused state of the current animation.
|
||||
*//**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @param {boolean} value - Sets the paused state of the current animation.
|
||||
* @name Phaser.AnimationManager#paused
|
||||
* @property {boolean} paused - Gets and sets the paused state of the current animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "paused", {
|
||||
|
||||
@@ -320,11 +309,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "paused", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @return {number} Returns the index of the current frame.
|
||||
*//**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @param {number} value - Sets the current frame on the Sprite and updates the texture cache for display.
|
||||
* @name Phaser.AnimationManager#frame
|
||||
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
|
||||
@@ -352,11 +338,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @return {string} Returns the name of the current frame if it has one.
|
||||
*//**
|
||||
* @memberof Phaser.AnimationManager
|
||||
* @param {string} value - Sets the current frame on the Sprite and updates the texture cache for display.
|
||||
* @name Phaser.AnimationManager#frameName
|
||||
* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -129,8 +128,7 @@ Phaser.Animation.Frame.prototype = {
|
||||
/**
|
||||
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
|
||||
*
|
||||
* @method setTrim
|
||||
* @memberof Phaser.Animation.Frame
|
||||
* @method Phaser.Animation.Frame#setTrim
|
||||
* @param {boolean} trimmed - If this frame was trimmed or not.
|
||||
* @param {number} actualWidth - The width of the frame before being trimmed.
|
||||
* @param {number} actualHeight - The height of the frame before being trimmed.
|
||||
|
||||
+11
-23
@@ -2,7 +2,6 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -33,8 +32,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
/**
|
||||
* Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
|
||||
*
|
||||
* @method addFrame
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#addFrame
|
||||
* @param {Phaser.Animation.Frame} frame - The frame to add to this FrameData set.
|
||||
* @return {Phaser.Animation.Frame} The frame that was just added.
|
||||
*/
|
||||
@@ -56,8 +54,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
/**
|
||||
* Get a Frame by its numerical index.
|
||||
*
|
||||
* @method getFrame
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#getFrame
|
||||
* @param {number} index - The index of the frame you want to get.
|
||||
* @return {Phaser.Animation.Frame} The frame, if found.
|
||||
*/
|
||||
@@ -75,8 +72,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
/**
|
||||
* Get a Frame by its frame name.
|
||||
*
|
||||
* @method getFrameByName
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#getFrameByName
|
||||
* @param {string} name - The name of the frame you want to get.
|
||||
* @return {Phaser.Animation.Frame} The frame, if found.
|
||||
*/
|
||||
@@ -94,8 +90,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
/**
|
||||
* Check if there is a Frame with the given name.
|
||||
*
|
||||
* @method checkFrameName
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#checkFrameName
|
||||
* @param {string} name - The name of the frame you want to check.
|
||||
* @return {boolean} True if the frame is found, otherwise false.
|
||||
*/
|
||||
@@ -113,8 +108,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
/**
|
||||
* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
|
||||
*
|
||||
* @method getFrameRange
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#getFrameRange
|
||||
* @param {number} start - The starting frame index.
|
||||
* @param {number} end - The ending frame index.
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
@@ -137,8 +131,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
|
||||
* The frames are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method getFrames
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#getFrames
|
||||
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
@@ -185,8 +178,7 @@ Phaser.Animation.FrameData.prototype = {
|
||||
* Returns all of the Frame indexes in this FrameData set.
|
||||
* The frames indexes are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method getFrameIndexes
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @method Phaser.Animation.FrameData#getFrameIndexes
|
||||
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
@@ -228,18 +220,14 @@ Phaser.Animation.FrameData.prototype = {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation.FrameData#total
|
||||
* @property {number} total - The total number of frames in this FrameData set.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
|
||||
|
||||
/**
|
||||
* Returns the total number of frames in this FrameData set.
|
||||
*
|
||||
* @method total
|
||||
* @memberof Phaser.Animation.FrameData
|
||||
* @return {number} The total number of frames in this FrameData set.
|
||||
*/
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -15,8 +14,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse a Sprite Sheet and extract the animation frame data from it.
|
||||
*
|
||||
* @method spriteSheet
|
||||
* @memberof Phaser.Animation.Parser
|
||||
* @method Phaser.Animation.Parser.spriteSheet
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {string} key - The Game.Cache asset key of the Sprite Sheet image.
|
||||
* @param {number} frameWidth - The fixed width of each frame of the animation.
|
||||
@@ -97,8 +95,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method JSONData
|
||||
* @memberof Phaser.Animation.Parser
|
||||
* @method Phaser.Animation.Parser.JSONData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
@@ -169,8 +166,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method JSONDataHash
|
||||
* @memberof Phaser.Animation.Parser
|
||||
* @method Phaser.Animation.Parser.JSONDataHash
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
@@ -244,8 +240,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the XML data and extract the animation frame data from it.
|
||||
*
|
||||
* @method XMLData
|
||||
* @memberof Phaser.Animation.Parser
|
||||
* @method Phaser.Animation.Parser.XMLData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
|
||||
Reference in New Issue
Block a user