Input, Loader and Math docs tidied up.

This commit is contained in:
Richard Davey
2013-10-02 15:05:55 +01:00
parent 1a2dc05609
commit 868ae81bab
89 changed files with 62657 additions and 1080 deletions
+1 -2
View File
@@ -2,14 +2,13 @@
* @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.PluginManager
*/
/**
* Description.
*
* @class Phaser.PluginManager
* @classdesc PPhaser - PluginManager
* @classdesc Phaser - PluginManager
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Description} parent - Description.
+43 -44
View File
@@ -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.InputHandler
*/
/**
@@ -14,16 +13,16 @@
*/
Phaser.InputHandler = function (sprite) {
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = sprite.game;
/**
* @property {Phaser.Sprite} sprite - Description.
*/
this.sprite = sprite;
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = sprite.game;
/**
* @property {boolean} enabled - Description.
* @default
@@ -195,7 +194,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method start
* @method Phaser.InputHandler#start
* @param {number} priority - Description.
* @param {boolean} useHandCursor - Description.
* @return {Phaser.Sprite} Description.
@@ -253,7 +252,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method reset
* @method Phaser.InputHandler#reset
*/
reset: function () {
@@ -281,7 +280,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method stop
* @method Phaser.InputHandler#stop
*/
stop: function () {
@@ -301,7 +300,7 @@ Phaser.InputHandler.prototype = {
/**
* Clean up memory.
* @method destroy
* @method Phaser.InputHandler#destroy
*/
destroy: function () {
@@ -317,7 +316,7 @@ Phaser.InputHandler.prototype = {
/**
* The x coordinate of the Input pointer, relative to the top-left of the parent Sprite.
* This value is only set when the pointer is over this Sprite.
* @method pointerX
* @method Phaser.InputHandler#pointerX
* @param {Pointer} pointer
* @return {number} The x coordinate of the Input pointer.
*/
@@ -332,7 +331,7 @@ Phaser.InputHandler.prototype = {
/**
* The y coordinate of the Input pointer, relative to the top-left of the parent Sprite
* This value is only set when the pointer is over this Sprite.
* @method pointerY
* @method Phaser.InputHandler#pointerY
* @param {Pointer} pointer
* @return {number} The y coordinate of the Input pointer.
*/
@@ -346,7 +345,7 @@ Phaser.InputHandler.prototype = {
/**
* If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
* @method pointerDown
* @method Phaser.InputHandler#pointerDown
* @param {Pointer} pointer
* @return {boolean}
*/
@@ -360,7 +359,7 @@ Phaser.InputHandler.prototype = {
/**
* If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
* @method pointerUp
* @method Phaser.InputHandler#pointerUp
* @param {Pointer} pointer
* @return {boolean}
*/
@@ -374,7 +373,7 @@ Phaser.InputHandler.prototype = {
/**
* A timestamp representing when the Pointer first touched the touchscreen.
* @method pointerTimeDown
* @method Phaser.InputHandler#pointerTimeDown
* @param {Pointer} pointer
* @return {number}
*/
@@ -388,7 +387,7 @@ Phaser.InputHandler.prototype = {
/**
* A timestamp representing when the Pointer left the touchscreen.
* @method pointerTimeUp
* @method Phaser.InputHandler#pointerTimeUp
* @param {Pointer} pointer
* @return {number}
*/
@@ -402,7 +401,7 @@ Phaser.InputHandler.prototype = {
/**
* Is the Pointer over this Sprite?
* @method pointerOver
* @method Phaser.InputHandler#pointerOver
* @param {Pointer} pointer
* @return {bool
*/
@@ -416,7 +415,7 @@ Phaser.InputHandler.prototype = {
/**
* Is the Pointer outside of this Sprite?
* @method pointerOut
* @method Phaser.InputHandler#pointerOut
* @param {Pointer} pointer
* @return {boolean}
*/
@@ -430,7 +429,7 @@ Phaser.InputHandler.prototype = {
/**
* A timestamp representing when the Pointer first touched the touchscreen.
* @method pointerTimeOver
* @method Phaser.InputHandler#pointerTimeOver
* @param {Pointer} pointer
* @return {number}
*/
@@ -444,7 +443,7 @@ Phaser.InputHandler.prototype = {
/**
* A timestamp representing when the Pointer left the touchscreen.
* @method pointerTimeOut
* @method Phaser.InputHandler#pointerTimeOut
* @param {Pointer} pointer
* @return {number}
*/
@@ -458,7 +457,7 @@ Phaser.InputHandler.prototype = {
/**
* Is this sprite being dragged by the mouse or not?
* @method pointerTimeOut
* @method Phaser.InputHandler#pointerTimeOut
* @param {Pointer} pointer
* @return {number}
*/
@@ -472,7 +471,7 @@ Phaser.InputHandler.prototype = {
/**
* Checks if the given pointer is over this Sprite.
* @method checkPointerOver
* @method Phaser.InputHandler#checkPointerOver
* @param {Pointer} pointer
* @return {boolean}
*/
@@ -510,7 +509,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method checkPixel
* @method Phaser.InputHandler#checkPixel
* @param {Description} x - Description.
* @param {Description} y - Description.
* @return {boolean}
@@ -543,7 +542,7 @@ Phaser.InputHandler.prototype = {
/**
* Update.
* @method update
* @method Phaser.InputHandler#update
* @param {Pointer} pointer
*/
update: function (pointer) {
@@ -576,7 +575,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method _pointerOverHandler
* @method Phaser.InputHandler#_pointerOverHandler
* @private
* @param {Pointer} pointer
*/
@@ -601,7 +600,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method _pointerOutHandler
* @method Phaser.InputHandler#_pointerOutHandler
* @private
* @param {Pointer} pointer
*/
@@ -622,7 +621,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method _touchedHandler
* @method Phaser.InputHandler#_touchedHandler
* @private
* @param {Pointer} pointer
*/
@@ -654,7 +653,7 @@ Phaser.InputHandler.prototype = {
/**
* Description.
* @method _releasedHandler
* @method Phaser.InputHandler#_releasedHandler
* @private
* @param {Pointer} pointer
*/
@@ -694,7 +693,7 @@ Phaser.InputHandler.prototype = {
/**
* Updates the Pointer drag on this Sprite.
* @method updateDrag
* @method Phaser.InputHandler#updateDrag
* @param {Pointer} pointer
* @return {boolean}
*/
@@ -738,7 +737,7 @@ Phaser.InputHandler.prototype = {
/**
* Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method justOver
* @method Phaser.InputHandler#justOver
* @param {Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just over.
* @return {boolean}
@@ -754,7 +753,7 @@ Phaser.InputHandler.prototype = {
/**
* Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method justOut
* @method Phaser.InputHandler#justOut
* @param {Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just out.
* @return {boolean}
@@ -770,7 +769,7 @@ Phaser.InputHandler.prototype = {
/**
* Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method justPressed
* @method Phaser.InputHandler#justPressed
* @param {Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just over.
* @return {boolean}
@@ -786,7 +785,7 @@ Phaser.InputHandler.prototype = {
/**
* Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method justReleased
* @method Phaser.InputHandler#justReleased
* @param {Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just out.
* @return {boolean}
@@ -802,7 +801,7 @@ Phaser.InputHandler.prototype = {
/**
* If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
* @method overDuration
* @method Phaser.InputHandler#overDuration
* @param {Pointer} pointer
* @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over.
*/
@@ -821,7 +820,7 @@ Phaser.InputHandler.prototype = {
/**
* If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
* @method downDuration
* @method Phaser.InputHandler#downDuration
* @param {Pointer} pointer
* @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.
*/
@@ -840,7 +839,7 @@ Phaser.InputHandler.prototype = {
/**
* Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
* @method enableDrag
* @method Phaser.InputHandler#enableDrag
* @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.
* @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group.
* @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.
@@ -881,7 +880,7 @@ Phaser.InputHandler.prototype = {
/**
* Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.
* @method disableDrag
* @method Phaser.InputHandler#disableDrag
*/
disableDrag: function () {
@@ -901,7 +900,7 @@ Phaser.InputHandler.prototype = {
/**
* Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
* @method startDrag
* @method Phaser.InputHandler#startDrag
*/
startDrag: function (pointer) {
@@ -932,7 +931,7 @@ Phaser.InputHandler.prototype = {
/**
* Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
* @method stopDrag
* @method Phaser.InputHandler#stopDrag
*/
stopDrag: function (pointer) {
@@ -953,7 +952,7 @@ Phaser.InputHandler.prototype = {
/**
* Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!
* @method setDragLock
* @method Phaser.InputHandler#setDragLock
* @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false
* @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false
*/
@@ -970,7 +969,7 @@ Phaser.InputHandler.prototype = {
/**
* Make this Sprite snap to the given grid either during drag or when it's released.
* For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.
* @method enableSnap
* @method Phaser.InputHandler#enableSnap
* @param snapX The width of the grid cell in pixels
* @param snapY The height of the grid cell in pixels
* @param onDrag If true the sprite will snap to the grid while being dragged
@@ -990,7 +989,7 @@ Phaser.InputHandler.prototype = {
/**
* Stops the sprite from snapping to a grid during drag or release.
* @method disableSnap
* @method Phaser.InputHandler#disableSnap
*/
disableSnap: function () {
@@ -1001,7 +1000,7 @@ Phaser.InputHandler.prototype = {
/**
* Bounds Rect check for the sprite drag
* @method checkBoundsRect
* @method Phaser.InputHandler#checkBoundsRect
*/
checkBoundsRect: function () {
@@ -1027,7 +1026,7 @@ Phaser.InputHandler.prototype = {
/**
* Parent Sprite Bounds check for the sprite drag.
* @method checkBoundsSprite
* @method Phaser.InputHandler#checkBoundsSprite
*/
checkBoundsSprite: function () {
+3 -3
View File
@@ -42,21 +42,21 @@ Phaser.Keyboard = function (game) {
* @property {boolean} disabled - The disabled state of the Keyboard.
* @default
*/
disabled: false,
this.disabled = false;
/**
* @property {function} _onKeyDown
* @private
* @default
*/
_onKeyDown: null,
this._onKeyDown = null;
/**
* @property {function} _onKeyUp
* @private
* @default
*/
_onKeyUp: null,
this._onKeyUp = null;
/**
* @property {Object} callbackContext - The context under which the callbacks are run.
+35 -42
View File
@@ -2,10 +2,8 @@
* @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.MSPointer
*/
/**
* Phaser - MSPointer constructor.
*
@@ -46,48 +44,43 @@ Phaser.MSPointer = function (game) {
*/
this.mouseUpCallback = null;
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @property {boolean} disabled
*/
this.disabled = false;
/**
* Description.
* @property {Description} _onMSPointerDown
* @private
* @default
*/
this._onMSPointerDown = null;
/**
* Description.
* @property {Description} _onMSPointerMove
* @private
* @default
*/
this._onMSPointerMove = null;
/**
* Description.
* @property {Description} _onMSPointerUp
* @private
* @default
*/
this._onMSPointerUp = null;
};
Phaser.MSPointer.prototype = {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
game: null,
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @property {boolean} disabled
*/
disabled: false,
/**
* Description.
* @property {Description} _onMSPointerDown
* @private
* @default
*/
_onMSPointerDown: null,
/**
* Description.
* @property {Description} _onMSPointerMove
* @private
* @default
*/
_onMSPointerMove: null,
/**
* Description.
* @property {Description} _onMSPointerUp
* @private
* @default
*/
_onMSPointerUp: null,
/**
* Starts the event listeners running.
* @method start
* @method Phaser.MSPointer#start
*/
start: function () {
@@ -120,7 +113,7 @@ Phaser.MSPointer.prototype = {
/**
* Description.
* @method onPointerDown
* @method Phaser.MSPointer#onPointerDown
* @param {Any} event
**/
onPointerDown: function (event) {
@@ -139,7 +132,7 @@ Phaser.MSPointer.prototype = {
/**
* Description.
* @method onPointerMove
* @method Phaser.MSPointer#onPointerMove
* @param {Any} event
**/
onPointerMove: function (event) {
@@ -158,7 +151,7 @@ Phaser.MSPointer.prototype = {
/**
* Description.
* @method onPointerUp
* @method Phaser.MSPointer#onPointerUp
* @param {Any} event
**/
onPointerUp: function (event) {
@@ -177,7 +170,7 @@ Phaser.MSPointer.prototype = {
/**
* Stop the event listeners.
* @method stop
* @method Phaser.MSPointer#stop
*/
stop: function () {
+33 -26
View File
@@ -2,10 +2,8 @@
* @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.Mouse
*/
/**
* Phaser - Mouse constructor.
*
@@ -22,7 +20,7 @@ Phaser.Mouse = function (game) {
this.game = game;
/**
* @property {Phaser.Game} callbackContext - Description.
* @property {Object} callbackContext - Description.
*/
this.callbackContext = this.game;
@@ -44,36 +42,45 @@ Phaser.Mouse = function (game) {
*/
this.mouseUpCallback = null;
};
Phaser.Mouse.LEFT_BUTTON = 0;
Phaser.Mouse.MIDDLE_BUTTON = 1;
Phaser.Mouse.RIGHT_BUTTON = 2;
Phaser.Mouse.prototype = {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
game: null,
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @property {boolean} disabled
* @default
*/
disabled: false,
this.disabled = false;
/**
* If the mouse has been Pointer Locked successfully this will be set to true.
* @property {boolean} locked
* @default
*/
locked: false,
this.locked = false;
};
/**
* @constant
* @type {number}
*/
Phaser.Mouse.LEFT_BUTTON = 0;
/**
* @constant
* @type {number}
*/
Phaser.Mouse.MIDDLE_BUTTON = 1;
/**
* @constant
* @type {number}
*/
Phaser.Mouse.RIGHT_BUTTON = 2;
Phaser.Mouse.prototype = {
/**
* Starts the event listeners running.
* @method start
* @method Phaser.Mouse#start
*/
start: function () {
@@ -105,7 +112,7 @@ Phaser.Mouse.prototype = {
/**
* Description.
* @method onMouseDown
* @method Phaser.Mouse#onMouseDown
* @param {MouseEvent} event
*/
onMouseDown: function (event) {
@@ -128,7 +135,7 @@ Phaser.Mouse.prototype = {
/**
* Description
* @method onMouseMove
* @method Phaser.Mouse#onMouseMove
* @param {MouseEvent} event
*/
onMouseMove: function (event) {
@@ -151,7 +158,7 @@ Phaser.Mouse.prototype = {
/**
* Description.
* @method onMouseUp
* @method Phaser.Mouse#onMouseUp
* @param {MouseEvent} event
*/
onMouseUp: function (event) {
@@ -174,7 +181,7 @@ Phaser.Mouse.prototype = {
/**
* Description.
* @method requestPointerLock
* @method Phaser.Mouse#requestPointerLock
*/
requestPointerLock: function () {
@@ -201,7 +208,7 @@ Phaser.Mouse.prototype = {
/**
* Description.
* @method pointerLockChange
* @method Phaser.Mouse#pointerLockChange
* @param {MouseEvent} event
*/
pointerLockChange: function (event) {
@@ -223,7 +230,7 @@ Phaser.Mouse.prototype = {
/**
* Description.
* @method releasePointerLock
* @method Phaser.Mouse#releasePointerLock
*/
releasePointerLock: function () {
@@ -239,7 +246,7 @@ Phaser.Mouse.prototype = {
/**
* Stop the event listeners.
* @method stop
* @method Phaser.Mouse#stop
*/
stop: function () {
+32 -27
View File
@@ -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.Pointer
*/
/**
@@ -16,6 +15,16 @@
*/
Phaser.Pointer = function (game, id) {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* @property {Description} id - Description.
*/
this.id = id;
/**
* Local private variable to store the status of dispatching a hold event.
* @property {boolean} _holdSent
@@ -194,16 +203,6 @@ Phaser.Pointer = function (game, id) {
*/
this.targetObject = null;
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* @property {Description} id - Description.
*/
this.id = id;
/**
* Description.
* @property {boolean} isDown - Description.
@@ -240,7 +239,7 @@ Phaser.Pointer.prototype = {
/**
* Called when the Pointer is pressed onto the touchscreen.
* @method start
* @method Phaser.Pointer#start
* @param {Any} event
*/
start: function (event) {
@@ -305,7 +304,7 @@ Phaser.Pointer.prototype = {
/**
* Description.
* @method update
* @method Phaser.Pointer#update
*/
update: function () {
@@ -342,7 +341,7 @@ Phaser.Pointer.prototype = {
/**
* Called when the Pointer is moved
* @method move
* @method Phaser.Pointer#move
* @param {Any} event
*/
move: function (event) {
@@ -482,7 +481,7 @@ Phaser.Pointer.prototype = {
/**
* Called when the Pointer leaves the target area.
* @method leave
* @method Phaser.Pointer#leave
* @param {Any} event
*/
leave: function (event) {
@@ -494,7 +493,7 @@ Phaser.Pointer.prototype = {
/**
* Called when the Pointer leaves the touchscreen.
* @method stop
* @method Phaser.Pointer#stop
* @param {Any} event
*/
stop: function (event) {
@@ -573,7 +572,7 @@ Phaser.Pointer.prototype = {
/**
* The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.
* @method justPressed
* @method Phaser.Pointer#justPressed
* @param {number} [duration]
* @return {boolean}
*/
@@ -587,7 +586,7 @@ Phaser.Pointer.prototype = {
/**
* The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.
* @method justReleased
* @method Phaser.Pointer#justReleased
* @param {number} [duration]
* @return {boolean}
*/
@@ -601,7 +600,7 @@ Phaser.Pointer.prototype = {
/**
* Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
* @method reset
* @method Phaser.Pointer#reset
*/
reset: function () {
@@ -629,7 +628,7 @@ Phaser.Pointer.prototype = {
/**
* Returns a string representation of this object.
* @method toString
* @method Phaser.Pointer#toString
* @return {string} A string representation of the instance.
**/
toString: function () {
@@ -640,7 +639,9 @@ Phaser.Pointer.prototype = {
/**
* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
* @return {number}
* @name Phaser.Pointer#duration
* @property {number} duration - How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
* @readonly
*/
Object.defineProperty(Phaser.Pointer.prototype, "duration", {
@@ -658,9 +659,11 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", {
});
/**
* Gets the X value of this Pointer in world coordinates based on the given camera.
* @return {Description}
*/
* Gets the X value of this Pointer in world coordinates based on the world camera.
* @name Phaser.Pointer#worldX
* @property {number} duration - The X value of this Pointer in world coordinates based on the world camera.
* @readonly
*/
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
get: function () {
@@ -672,9 +675,11 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
});
/**
* Gets the Y value of this Pointer in world coordinates based on the given camera.
* @return {Description}
*/
* Gets the Y value of this Pointer in world coordinates based on the world camera.
* @name Phaser.Pointer#worldY
* @property {number} duration - The Y value of this Pointer in world coordinates based on the world camera.
* @readonly
*/
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
get: function () {
+67 -75
View File
@@ -2,100 +2,92 @@
* @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.Touch
*/
/**
* Phaser - Touch
* Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch.
*
* @class
*
* @class Phaser.Touch
* @classdesc The Touch class handles touch interactions with the game and the resulting Pointer objects.
* {@link http://www.w3.org/TR/touch-events/}
* {@link https://developer.mozilla.org/en-US/docs/DOM/TouchList}
* {@link http://www.html5rocks.com/en/mobile/touchandmouse/}
* <p>Note: Android 2.x only supports 1 touch event at once, no multi-touch.
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Touch = function (game) {
/**
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* @property {Phaser.Game} callbackContext - Description.
*/
this.game = game;
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @method Phaser.Touch#disabled
* @return {boolean}
*/
this.disabled = false;
/**
* @property {Phaser.Game} callbackContext - Description.
*/
this.callbackContext = this.game;
/**
* @property {Phaser.Game} touchStartCallback - Description.
* @default
/**
* @property {Phaser.Game} touchStartCallback - Description.
* @default
*/
this.touchStartCallback = null;
/**
* @property {Phaser.Game} touchMoveCallback - Description.
* @default
/**
* @property {Phaser.Game} touchMoveCallback - Description.
* @default
*/
this.touchMoveCallback = null;
/**
* @property {Phaser.Game} touchEndCallback - Description.
* @default
/**
* @property {Phaser.Game} touchEndCallback - Description.
* @default
*/
this.touchEndCallback = null;
/**
* @property {Phaser.Game} touchEnterCallback - Description.
* @default
/**
* @property {Phaser.Game} touchEnterCallback - Description.
* @default
*/
this.touchEnterCallback = null;
/**
* @property {Phaser.Game} touchLeaveCallback - Description.
* @default
/**
* @property {Phaser.Game} touchLeaveCallback - Description.
* @default
*/
this.touchLeaveCallback = null;
/**
* @property {Description} touchCancelCallback - Description.
* @default
/**
* @property {Description} touchCancelCallback - Description.
* @default
*/
this.touchCancelCallback = null;
/**
* @property {boolean} preventDefault - Description.
* @default
/**
* @property {boolean} preventDefault - Description.
* @default
*/
this.preventDefault = true;
this._onTouchStart = null;
this._onTouchMove = null;
this._onTouchEnd = null;
this._onTouchEnter = null;
this._onTouchLeave = null;
this._onTouchCancel = null;
this._onTouchMove = null;
};
Phaser.Touch.prototype = {
game: null,
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @method disabled
* @return {boolean}
*/
disabled: false,
_onTouchStart: null,
_onTouchMove: null,
_onTouchEnd: null,
_onTouchEnter: null,
_onTouchLeave: null,
_onTouchCancel: null,
_onTouchMove: null,
/**
* Starts the event listeners running.
* @method start
* @method Phaser.Touch#start
*/
start: function () {
@@ -139,8 +131,8 @@ Phaser.Touch.prototype = {
/**
* Consumes all touchmove events on the document (only enable this if you know you need it!).
* @method consumeTouchMove
**/
* @method Phaser.Touch#consumeTouchMove
*/
consumeDocumentTouches: function () {
this._documentTouchMove = function (event) {
@@ -151,11 +143,11 @@ Phaser.Touch.prototype = {
},
/**
/**
* Description.
* @method onTouchStart
* @method Phaser.Touch#onTouchStart
* @param {Any} event
**/
*/
onTouchStart: function (event) {
if (this.touchStartCallback)
@@ -183,12 +175,12 @@ Phaser.Touch.prototype = {
},
/**
/**
* Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome).
* Occurs for example on iOS when you put down 4 fingers and the app selector UI appears.
* @method onTouchCancel
* @method Phaser.Touch#onTouchCancel
* @param {Any} event
**/
*/
onTouchCancel: function (event) {
if (this.touchCancelCallback)
@@ -215,12 +207,12 @@ Phaser.Touch.prototype = {
},
/**
/**
* For touch enter and leave its a list of the touch points that have entered or left the target.
* Doesn't appear to be supported by most browsers on a canvas element yet.
* @method onTouchEnter
* @method Phaser.Touch#onTouchEnter
* @param {Any} event
**/
*/
onTouchEnter: function (event) {
if (this.touchEnterCallback)
@@ -245,12 +237,12 @@ Phaser.Touch.prototype = {
},
/**
/**
* For touch enter and leave its a list of the touch points that have entered or left the target.
* Doesn't appear to be supported by most browsers on a canvas element yet.
* @method onTouchLeave
* @method Phaser.Touch#onTouchLeave
* @param {Any} event
**/
*/
onTouchLeave: function (event) {
if (this.touchLeaveCallback)
@@ -270,11 +262,11 @@ Phaser.Touch.prototype = {
},
/**
/**
* Description.
* @method onTouchMove
* @method Phaser.Touch#onTouchMove
* @param {Any} event
**/
*/
onTouchMove: function (event) {
if (this.touchMoveCallback)
@@ -294,11 +286,11 @@ Phaser.Touch.prototype = {
},
/**
/**
* Description.
* @method onTouchEnd
* @method Phaser.Touch#onTouchEnd
* @param {Any} event
**/
*/
onTouchEnd: function (event) {
if (this.touchEndCallback)
@@ -321,9 +313,9 @@ Phaser.Touch.prototype = {
},
/**
/**
* Stop the event listeners.
* @method stop
* @method Phaser.Touch#stop
*/
stop: function () {
+170 -96
View File
@@ -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.Cache
*/
/**
@@ -70,11 +69,12 @@ Phaser.Cache = function (game) {
Phaser.Cache.prototype = {
/**
* Add a new canvas.
* @param {string} key - Asset key for this canvas.
* @param {HTMLCanvasElement} canvas - Canvas DOM element.
* @param {CanvasRenderingContext2D} context - Render context of this canvas.
*/
* Add a new canvas object in to the cache.
* @method Phaser.Cache#addCanvas
* @param {string} key - Asset key for this canvas.
* @param {HTMLCanvasElement} canvas - Canvas DOM element.
* @param {CanvasRenderingContext2D} context - Render context of this canvas.
*/
addCanvas: function (key, canvas, context) {
this._canvases[key] = { canvas: canvas, context: context };
@@ -82,10 +82,12 @@ Phaser.Cache.prototype = {
},
/**
* Add a new canvas.
* @param key {string} Asset key for this canvas.
* @param canvas {RenderTexture} A RenderTexture.
*/
* Add a new Phaser.RenderTexture in to the cache.
*
* @method Phaser.Cache#addRenderTexture
* @param {string} key - The unique key by which you will reference this object.
* @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture.
*/
addRenderTexture: function (key, texture) {
var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', '');
@@ -95,14 +97,16 @@ Phaser.Cache.prototype = {
},
/**
* Add a new sprite sheet.
* @param {string} key - Asset key for the sprite sheet.
* @param {string} url - URL of this sprite sheet file.
* @param {object} data - Extra sprite sheet data.
* @param {number} frameWidth - Width of the sprite sheet.
* @param {number} frameHeight - Height of the sprite sheet.
* @param {number} frameMax - How many frames stored in the sprite sheet.
*/
* Add a new sprite sheet in to the cache.
*
* @method Phaser.Cache#addSpriteSheet
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this sprite sheet file.
* @param {object} data - Extra sprite sheet data.
* @param {number} frameWidth - Width of the sprite sheet.
* @param {number} frameHeight - Height of the sprite sheet.
* @param {number} frameMax - How many frames stored in the sprite sheet.
*/
addSpriteSheet: function (key, url, data, frameWidth, frameHeight, frameMax) {
this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
@@ -115,12 +119,15 @@ Phaser.Cache.prototype = {
},
/**
* Add a new tilemap.
* @param {string} key - Asset key for the texture atlas.
* @param {string} url - URL of this texture atlas file.
* @param {object} data - Extra texture atlas data.
* @param {object} atlasData - Texture atlas frames data.
*/
* Add a new tilemap.
*
* @method Phaser.Cache#addTilemap
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of the tilemap image.
* @param {object} data - Tilemap data.
* @param {object} mapData - The tilemap data object.
* @param {number} format - The format of the tilemap data.
*/
addTilemap: function (key, url, data, mapData, format) {
this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format };
@@ -131,13 +138,15 @@ Phaser.Cache.prototype = {
},
/**
* Add a new texture atlas.
* @param {string} key - Asset key for the texture atlas.
* @param {string} url - URL of this texture atlas file.
* @param {object} data - Extra texture atlas data.
* @param {object} atlasData - Texture atlas frames data.
* @param {Description} format - Description.
*/
* Add a new texture atlas.
*
* @method Phaser.Cache#addTextureAtlas
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this texture atlas file.
* @param {object} data - Extra texture atlas data.
* @param {object} atlasData - Texture atlas frames data.
* @param {number} format - The format of the texture atlas.
*/
addTextureAtlas: function (key, url, data, atlasData, format) {
this._images[key] = { url: url, data: data, spriteSheet: true };
@@ -161,12 +170,14 @@ Phaser.Cache.prototype = {
},
/**
* Add a new Bitmap Font.
* @param {string} key - Asset key for the font texture.
* @param {string} url - URL of this font xml file.
* @param {object} data - Extra font data.
* @param xmlData {object} Texture atlas frames data.
*/
* Add a new Bitmap Font.
*
* @method Phaser.Cache#addBitmapFont
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this font xml file.
* @param {object} data - Extra font data.
* @param xmlData {object} Texture atlas frames data.
*/
addBitmapFont: function (key, url, data, xmlData) {
this._images[key] = { url: url, data: data, spriteSheet: true };
@@ -180,10 +191,10 @@ Phaser.Cache.prototype = {
},
/**
* Adds a default image to be used when a key is wrong / missing.
* Is mapped to the key __default
* @method addDefaultImage
*/
* Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default.
*
* @method Phaser.Cache#addDefaultImage
*/
addDefaultImage: function () {
this._images['__default'] = { url: null, data: null, spriteSheet: false };
@@ -200,12 +211,13 @@ Phaser.Cache.prototype = {
},
/**
* Add a new image.
* @method addImage
* @param {string} key - Asset key for the image.
* @param {string} url - URL of this image file.
* @param {object} data - Extra image data.
*/
* Add a new image.
*
* @method Phaser.Cache#addImage
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this image file.
* @param {object} data - Extra image data.
*/
addImage: function (key, url, data) {
this._images[key] = { url: url, data: data, spriteSheet: false };
@@ -217,12 +229,15 @@ Phaser.Cache.prototype = {
},
/**
* Add a new sound.
* @method addSound
* @param {string} key - Asset key for the sound.
* @param {string} url - URL of this sound file.
* @param {object} data - Extra sound data.
*/
* Add a new sound.
*
* @method Phaser.Cache#addSound
* @param {string} key - Asset key for the sound.
* @param {string} url - URL of this sound file.
* @param {object} data - Extra sound data.
* @param {boolean} webAudio - True if the file is using web audio.
* @param {boolean} audioTag - True if the file is using legacy HTML audio.
*/
addSound: function (key, url, data, webAudio, audioTag) {
webAudio = webAudio || true;
@@ -241,10 +256,10 @@ Phaser.Cache.prototype = {
},
/**
* Reload a sound.
* @method reloadSound
* @param {string} key - Asset key for the sound.
*/
* Reload a sound.
* @method Phaser.Cache#reloadSound
* @param {string} key - Asset key for the sound.
*/
reloadSound: function (key) {
var _this = this;
@@ -262,10 +277,10 @@ Phaser.Cache.prototype = {
},
/**
* Description.
* @method reloadSoundComplete
* @param {string} key - Asset key for the sound.
*/
* Description.
* @method Phaser.Cache#reloadSoundComplete
* @param {string} key - Asset key for the sound.
*/
reloadSoundComplete: function (key) {
if (this._sounds[key])
@@ -277,10 +292,10 @@ Phaser.Cache.prototype = {
},
/**
* Description.
* @method updateSound
* @param {string} key - Asset key for the sound.
*/
* Description.
* @method Phaser.Cache#updateSound
* @param {string} key - Asset key for the sound.
*/
updateSound: function (key, property, value) {
if (this._sounds[key])
@@ -292,6 +307,8 @@ Phaser.Cache.prototype = {
/**
* Add a new decoded sound.
*
* @method Phaser.Cache#decodedSound
* @param {string} key - Asset key for the sound.
* @param {object} data - Extra sound data.
*/
@@ -305,6 +322,8 @@ Phaser.Cache.prototype = {
/**
* Add a new text data.
*
* @method Phaser.Cache#addText
* @param {string} key - Asset key for the text data.
* @param {string} url - URL of this text data file.
* @param {object} data - Extra text data.
@@ -319,7 +338,9 @@ Phaser.Cache.prototype = {
},
/**
* Get canvas by key.
* Get acanvas object from the cache by its key.
*
* @method Phaser.Cache#getCanvas
* @param {string} key - Asset key of the canvas you want.
* @return {object} The canvas you want.
*/
@@ -335,6 +356,8 @@ Phaser.Cache.prototype = {
/**
* Checks if an image key exists.
*
* @method Phaser.Cache#checkImageKey
* @param {string} key - Asset key of the image you want.
* @return {boolean} True if the key exists, otherwise false.
*/
@@ -351,6 +374,8 @@ Phaser.Cache.prototype = {
/**
* Get image data by key.
*
* @method Phaser.Cache#getImage
* @param {string} key - Asset key of the image you want.
* @return {object} The image data you want.
*/
@@ -366,8 +391,10 @@ Phaser.Cache.prototype = {
/**
* Get tilemap data by key.
*
* @method Phaser.Cache#getTilemap
* @param {string} key - Asset key of the tilemap you want.
* @return {object} The tilemap data. The tileset image is in the data property, the map data in mapData.
* @return {Phaser.Tilemap} The tilemap data. The tileset image is in the data property, the map data in mapData.
*/
getTilemap: function (key) {
@@ -381,8 +408,10 @@ Phaser.Cache.prototype = {
/**
* Get frame data by key.
*
* @method Phaser.Cache#getFrameData
* @param {string} key - Asset key of the frame data you want.
* @return {object} The frame data you want.
* @return {Phaser.Animation.FrameData} The frame data you want.
*/
getFrameData: function (key) {
@@ -396,8 +425,10 @@ Phaser.Cache.prototype = {
/**
* Get a single frame out of a frameData set by key.
*
* @method Phaser.Cache#getFrameByIndex
* @param {string} key - Asset key of the frame data you want.
* @return {object} The frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
*/
getFrameByIndex: function (key, frame) {
@@ -411,8 +442,10 @@ Phaser.Cache.prototype = {
/**
* Get a single frame out of a frameData set by key.
*
* @method Phaser.Cache#getFrameByName
* @param {string} key - Asset key of the frame data you want.
* @return {object} The frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
*/
getFrameByName: function (key, frame) {
@@ -426,8 +459,10 @@ Phaser.Cache.prototype = {
/**
* Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
*
* @method Phaser.Cache#getFrame
* @param {string} key - Asset key of the frame data you want.
* @return {object} The frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
*/
getFrame: function (key) {
@@ -441,8 +476,10 @@ Phaser.Cache.prototype = {
/**
* Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
*
* @method Phaser.Cache#getTextureFrame
* @param {string} key - Asset key of the frame data you want.
* @return {object} The frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
*/
getTextureFrame: function (key) {
@@ -456,8 +493,10 @@ Phaser.Cache.prototype = {
/**
* Get a RenderTexture by key.
*
* @method Phaser.Cache#getTexture
* @param {string} key - Asset key of the RenderTexture you want.
* @return {object} The RenderTexture you want.
* @return {Phaser.RenderTexture} The RenderTexture you want.
*/
getTexture: function (key) {
@@ -472,8 +511,10 @@ Phaser.Cache.prototype = {
/**
* Get sound by key.
*
* @method Phaser.Cache#getSound
* @param {string} key - Asset key of the sound you want.
* @return {object} The sound you want.
* @return {Phaser.Sound} The sound you want.
*/
getSound: function (key) {
@@ -488,6 +529,8 @@ Phaser.Cache.prototype = {
/**
* Get sound data by key.
*
* @method Phaser.Cache#getSoundData
* @param {string} key - Asset key of the sound you want.
* @return {object} The sound data you want.
*/
@@ -503,9 +546,11 @@ Phaser.Cache.prototype = {
},
/**
* Check whether an asset is decoded sound.
* Check if the given sound has finished decoding.
*
* @method Phaser.Cache#isSoundDecoded
* @param {string} key - Asset key of the sound you want.
* @return {object} The sound data you want.
* @return {boolean} The decoded state of the Sound object.
*/
isSoundDecoded: function (key) {
@@ -517,9 +562,11 @@ Phaser.Cache.prototype = {
},
/**
* Check whether an asset is decoded sound.
* Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.
*
* @method Phaser.Cache#isSoundReady
* @param {string} key - Asset key of the sound you want.
* @return {object} The sound data you want.
* @return {boolean} True if the sound is decoded and the device is not touch locked.
*/
isSoundReady: function (key) {
@@ -528,9 +575,11 @@ Phaser.Cache.prototype = {
},
/**
* Check whether an asset is sprite sheet.
* Check whether an image asset is sprite sheet or not.
*
* @method Phaser.Cache#isSpriteSheet
* @param {string} key - Asset key of the sprite sheet you want.
* @return {object} The sprite sheet data you want.
* @return {boolean} True if the image is a sprite sheet.
*/
isSpriteSheet: function (key) {
@@ -545,6 +594,8 @@ Phaser.Cache.prototype = {
/**
* Get text data by key.
*
* @method Phaser.Cache#getText
* @param {string} key - Asset key of the text data you want.
* @return {object} The text data you want.
*/
@@ -559,6 +610,14 @@ Phaser.Cache.prototype = {
},
/**
* Get the cache keys from a given array of objects.
* Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc.
*
* @method Phaser.Cache#getKeys
* @param {Array} array - An array of items to return the keys for.
* @return {Array} The array of item keys.
*/
getKeys: function (array) {
var output = [];
@@ -577,6 +636,8 @@ Phaser.Cache.prototype = {
/**
* Returns an array containing all of the keys of Images in the Cache.
*
* @method Phaser.Cache#getImageKeys
* @return {Array} The string based keys in the Cache.
*/
getImageKeys: function () {
@@ -585,6 +646,8 @@ Phaser.Cache.prototype = {
/**
* Returns an array containing all of the keys of Sounds in the Cache.
*
* @method Phaser.Cache#getSoundKeys
* @return {Array} The string based keys in the Cache.
*/
getSoundKeys: function () {
@@ -593,6 +656,8 @@ Phaser.Cache.prototype = {
/**
* Returns an array containing all of the keys of Text Files in the Cache.
*
* @method Phaser.Cache#getTextKeys
* @return {Array} The string based keys in the Cache.
*/
getTextKeys: function () {
@@ -600,40 +665,49 @@ Phaser.Cache.prototype = {
},
/**
* Description.
* @method removeCanvas
* Removes a canvas from the cache.
*
* @method Phaser.Cache#removeCanvas
* @param {string} key - Key of the asset you want to remove.
*/
removeCanvas: function (key) {
delete this._canvases[key];
},
/**
* Description.
* @method removeImage
*/
/**
* Removes an image from the cache.
*
* @method Phaser.Cache#removeImage
* @param {string} key - Key of the asset you want to remove.
*/
removeImage: function (key) {
delete this._images[key];
},
/**
* Description.
* @method removeSound
*/
/**
* Removes a sound from the cache.
*
* @method Phaser.Cache#removeSound
* @param {string} key - Key of the asset you want to remove.
*/
removeSound: function (key) {
delete this._sounds[key];
},
/**
* Description.
* @method removeText
*/
/**
* Removes a text from the cache.
*
* @method Phaser.Cache#removeText
* @param {string} key - Key of the asset you want to remove.
*/
removeText: function (key) {
delete this._text[key];
},
/**
* Clean up cache memory.
* @method destroy
* Clears the cache. Removes every local cache object reference.
*
* @method Phaser.Cache#destroy
*/
destroy: function () {
+93 -53
View File
@@ -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.Loader
*/
/**
@@ -116,19 +115,33 @@ Phaser.Loader = function (game) {
};
/**
* TextureAtlas data format constants
*/
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0;
/**
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_JSON_HASH = 1;
/**
* @constant
* @type {number}
*/
Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
Phaser.Loader.prototype = {
/**
* Description.
* You can set a Sprite to be a "preload" sprite by passing it to this method.
* A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
* This allows you to easily make loading bars for games.
*
* @method setPreloadSprite
* @param {Phaser.Sprite} sprite - Description.
* @param {number} direction - Description.
* @method Phaser.Loader#setPreloadSprite
* @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load.
* @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.
*/
setPreloadSprite: function (sprite, direction) {
@@ -153,7 +166,8 @@ Phaser.Loader.prototype = {
/**
* Check whether asset exists with a specific key.
* @method checkKeyExists
*
* @method Phaser.Loader#checkKeyExists
* @param {string} key - Key of the asset you want to check.
* @return {boolean} Return true if exists, otherwise return false.
*/
@@ -172,7 +186,8 @@ Phaser.Loader.prototype = {
/**
* Reset loader, this will remove all loaded assets.
* @method reset
*
* @method Phaser.Loader#reset
*/
reset: function () {
@@ -183,12 +198,14 @@ Phaser.Loader.prototype = {
},
/**
* Internal function that adds a new entry to the file list.
* @method addToFileList
* Internal function that adds a new entry to the file list. Do not call directly.
*
* @method Phaser.Loader#addToFileList
* @param {Description} type - Description.
* @param {string} key - Description.
* @param {string} url - URL of Description.
* @param {Description} properties - Description.
* @protected
*/
addToFileList: function (type, key, url, properties) {
@@ -219,7 +236,8 @@ Phaser.Loader.prototype = {
/**
* Add an image to the Loader.
* @method image
*
* @method Phaser.Loader#image
* @param {string} key - Unique asset key of this image file.
* @param {string} url - URL of image file.
* @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it
@@ -237,7 +255,8 @@ Phaser.Loader.prototype = {
/**
* Add a text file to the Loader.
* @method text
*
* @method Phaser.Loader#text
* @param {string} key - Unique asset key of the text file.
* @param {string} url - URL of the text file.
* @param {boolean} overwrite - True if Description.
@@ -254,8 +273,9 @@ Phaser.Loader.prototype = {
},
/**
* Add a new sprite sheet loading request.
* @method spritesheet
* Add a new sprite sheet to the loader.
*
* @method Phaser.Loader#spritesheet
* @param {string} key - Unique asset key of the sheet file.
* @param {string} url - URL of the sheet file.
* @param {number} frameWidth - Width of each single frame.
@@ -274,8 +294,9 @@ Phaser.Loader.prototype = {
},
/**
* Add a new audio file loading request.
* @method audio
* Add a new audio file to the loader.
*
* @method Phaser.Loader#audio
* @param {string} key - Unique asset key of the audio file.
* @param {Array} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ].
* @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
@@ -293,7 +314,8 @@ Phaser.Loader.prototype = {
/**
* Add a new tilemap loading request.
* @method tilemap
*
* @method Phaser.Loader#tilemap
* @param {string} key - Unique asset key of the tilemap data.
* @param {string} tilesetURL - The url of the tile set image file.
* @param {string} [mapDataURL] - The url of the map data file (csv/json)
@@ -340,7 +362,8 @@ Phaser.Loader.prototype = {
/**
* Add a new bitmap font loading request.
* @method bitmapFont
*
* @method Phaser.Loader#bitmapFont
* @param {string} key - Unique asset key of the bitmap font.
* @param {string} textureURL - The url of the font image file.
* @param {string} [xmlURL] - The url of the font data file (xml/fnt)
@@ -398,8 +421,9 @@ Phaser.Loader.prototype = {
},
/**
* Description.
* @method atlasJSONArray
* Add a new texture atlas to the loader. This atlas uses the JSON Array data format.
*
* @method Phaser.Loader#atlasJSONArray
* @param {string} key - Unique asset key of the bitmap font.
* @param {Description} atlasURL - The url of the Description.
* @param {Description} atlasData - Description.
@@ -411,8 +435,9 @@ Phaser.Loader.prototype = {
},
/**
* Description.
* @method atlasJSONHash
* Add a new texture atlas to the loader. This atlas uses the JSON Hash data format.
*
* @method Phaser.Loader#atlasJSONHash
* @param {string} key - Unique asset key of the bitmap font.
* @param {Description} atlasURL - The url of the Description.
* @param {Description} atlasData - Description.
@@ -424,8 +449,9 @@ Phaser.Loader.prototype = {
},
/**
* Description.
* @method atlasXML
* Add a new texture atlas to the loader. This atlas uses the Starling XML data format.
*
* @method Phaser.Loader#atlasXML
* @param {string} key - Unique asset key of the bitmap font.
* @param {Description} atlasURL - The url of the Description.
* @param {Description} atlasData - Description.
@@ -437,13 +463,14 @@ Phaser.Loader.prototype = {
},
/**
* Add a new texture atlas loading request.
* @method atlas
* Add a new texture atlas to the loader.
*
* @method Phaser.Loader#atlas
* @param {string} key - Unique asset key of the texture atlas file.
* @param {string} textureURL - The url of the texture atlas image file.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml)
* @param {object} [atlasData] - A JSON or XML data object.
* @param {number} [format] - A value describing the format of the data.
* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
* @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY.
*/
atlas: function (key, textureURL, atlasURL, atlasData, format) {
@@ -517,10 +544,11 @@ Phaser.Loader.prototype = {
},
/**
* Remove loading request of a file.
* @method removeFile
* @param key {string} Key of the file you want to remove.
*/
* Remove loading request of a file.
*
* @method Phaser.Loader#removeFile
* @param key {string} Key of the file you want to remove.
*/
removeFile: function (key) {
delete this._fileList[key];
@@ -528,9 +556,10 @@ Phaser.Loader.prototype = {
},
/**
* Remove all file loading requests.
* @method removeAll
*/
* Remove all file loading requests.
*
* @method Phaser.Loader#removeAll
*/
removeAll: function () {
this._fileList = {};
@@ -538,9 +567,10 @@ Phaser.Loader.prototype = {
},
/**
* Load assets.
* @method start
*/
* Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so.
*
* @method Phaser.Loader#start
*/
start: function () {
if (this.isLoading)
@@ -570,7 +600,8 @@ Phaser.Loader.prototype = {
/**
* Load files. Private method ONLY used by loader.
* @method loadFile
*
* @method Phaser.Loader#loadFile
* @private
*/
loadFile: function () {
@@ -664,9 +695,10 @@ Phaser.Loader.prototype = {
},
/**
* Load files. Private method ONLY used by loader.
* @method getAudioURL
* Private method ONLY used by loader.
* @method Phaser.Loader#getAudioURL
* @param {Description} urls - Description.
* @private
*/
getAudioURL: function (urls) {
@@ -690,7 +722,8 @@ Phaser.Loader.prototype = {
/**
* Error occured when load a file.
* @method fileError
*
* @method Phaser.Loader#fileError
* @param {string} key - Key of the error loading file.
*/
fileError: function (key) {
@@ -708,7 +741,8 @@ Phaser.Loader.prototype = {
/**
* Called when a file is successfully loaded.
* @method fileComplete
*
* @method Phaser.Loader#fileComplete
* @param {string} key - Key of the successfully loaded file.
*/
fileComplete: function (key) {
@@ -872,7 +906,8 @@ Phaser.Loader.prototype = {
/**
* Successfully loaded a JSON file.
* @method jsonLoadComplete
*
* @method Phaser.Loader#jsonLoadComplete
* @param {string} key - Key of the loaded JSON file.
*/
jsonLoadComplete: function (key) {
@@ -895,7 +930,8 @@ Phaser.Loader.prototype = {
/**
* Successfully loaded a CSV file.
* @method csvLoadComplete
*
* @method Phaser.Loader#csvLoadComplete
* @param {string} key - Key of the loaded CSV file.
*/
csvLoadComplete: function (key) {
@@ -911,7 +947,8 @@ Phaser.Loader.prototype = {
/**
* Error occured when load a JSON.
* @method dataLoadError
*
* @method Phaser.Loader#dataLoadError
* @param {string} key - Key of the error loading JSON file.
*/
dataLoadError: function (key) {
@@ -928,7 +965,8 @@ Phaser.Loader.prototype = {
/**
* Successfully loaded an XML file.
* @method xmlLoadComplete
*
* @method Phaser.Loader#xmlLoadComplete
* @param {string} key - Key of the loaded XML file.
*/
xmlLoadComplete: function (key) {
@@ -976,10 +1014,12 @@ Phaser.Loader.prototype = {
},
/**
* Handle loading next file.
* @param previousKey {string} Key of previous loaded asset.
* @param success {boolean} Whether the previous asset loaded successfully or not.
*/
* Handle loading next file.
*
* @param previousKey {string} Key of previous loaded asset.
* @param success {boolean} Whether the previous asset loaded successfully or not.
* @private
*/
nextFile: function (previousKey, success) {
this.progress = Math.round(this.progress + this._progressChunk);
+3 -4
View File
@@ -2,19 +2,18 @@
* @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.Parser
*/
/**
* Description of Phaser.Loader.Parser
* Phaser.Loader.Parser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.
*
* @class Phaser.Loader.Parser
* @class Phaser.Loader.Parser
*/
Phaser.Loader.Parser = {
/**
* Parse frame data from an XML file.
* @method Phaser.Loader.Parser.bitmapFont
* @param {object} xml - XML data you want to parse.
* @return {FrameData} Generated FrameData object.
*/
+118 -85
View File
@@ -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.Math
*/
/**
@@ -14,14 +13,13 @@ Phaser.Math = {
/**
* = 2 &pi;
* @method PI2
*
* @method Phaser.Math#PI2
*/
PI2: Math.PI * 2,
/**
* Two number are fuzzyEqual if their difference is less than &epsilon;.
* @method fuzzyEqual
* @method Phaser.Math#fuzzyEqual
* @param {number} a
* @param {number} b
* @param {number} epsilon
@@ -34,7 +32,7 @@ Phaser.Math = {
/**
* a is fuzzyLessThan b if it is less than b + &epsilon;.
* @method fuzzyEqual
* @method Phaser.Math#fuzzyEqual
* @param {number} a
* @param {number} b
* @param {number} epsilon
@@ -47,7 +45,7 @@ Phaser.Math = {
/**
* a is fuzzyGreaterThan b if it is more than b - &epsilon;.
* @method fuzzyGreaterThan
* @method Phaser.Math#fuzzyGreaterThan
* @param {number} a
* @param {number} b
* @param {number} epsilon
@@ -59,7 +57,7 @@ Phaser.Math = {
},
/**
* @method fuzzyCeil
* @method Phaser.Math#fuzzyCeil
* @param {number} val
* @param {number} epsilon
* @return {boolean} ceiling(val-&epsilon;)
@@ -70,7 +68,7 @@ Phaser.Math = {
},
/**
* @method fuzzyFloor
* @method Phaser.Math#fuzzyFloor
* @param {number} val
* @param {number} epsilon
* @return {boolean} floor(val-&epsilon;)
@@ -81,7 +79,9 @@ Phaser.Math = {
},
/**
* @method average
* Averages all values passed to the function and returns the result. You can pass as many parameters as you like.
* @method Phaser.Math#average
* @return {number} The average of all given values.
*/
average: function () {
@@ -102,16 +102,18 @@ Phaser.Math = {
},
/**
* @method truncate
* @method Phaser.Math#truncate
* @param {number} n
* @return {number}
*/
truncate: function (n) {
return (n > 0) ? Math.floor(n) : Math.ceil(n);
},
/**
* @method shear
* @param n
* @return n mod 1
* @method Phaser.Math#shear
* @param {number} n
* @return {number} n mod 1
*/
shear: function (n) {
return n % 1;
@@ -122,10 +124,11 @@ Phaser.Math = {
*
* Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.
*
* @method snapTo
* @method Phaser.Math#snapTo
* @param {number} input - The value to snap.
* @param {number} gap - The interval gap of the grid.
* @param {number} [start] - Optional starting offset for gap.
* @return {number}
*/
snapTo: function (input, gap, start) {
@@ -147,10 +150,11 @@ Phaser.Math = {
*
* Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
*
* @method snapToFloor
* @method Phaser.Math#snapToFloor
* @param {number} input - The value to snap.
* @param {number} gap - The interval gap of the grid.
* @param {number} [start] - Optional starting offset for gap.
* @return {number}
*/
snapToFloor: function (input, gap, start) {
@@ -172,10 +176,11 @@ Phaser.Math = {
*
* Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20.
*
* @method snapToCeil
* @method Phaser.Math#snapToCeil
* @param {number} input - The value to snap.
* @param {number} gap - The interval gap of the grid.
* @param {number} [start] - Optional starting offset for gap.
* @return {number}
*/
snapToCeil: function (input, gap, start) {
@@ -195,10 +200,11 @@ Phaser.Math = {
/**
* Snaps a value to the nearest value in an array.
* @method
* @method Phaser.Math#snapToInArray
* @param {number} input
* @param {array} arr
* @param {boolean} sort - True if the array needs to be sorted.
* @return {number}
*/
snapToInArray: function (input, arr, sort) {
@@ -255,10 +261,11 @@ Phaser.Math = {
* Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
* because we are rounding 100011.1011011011011011 which rounds up.
*
* @method roundTo
* @method Phaser.Math#roundTo
* @param {number} value - The value to round.
* @param {number} place - The place to round to.
* @param {number} base - The base to round in... default is 10 for decimal.
* @return {number}
*/
roundTo: function (value, place, base) {
@@ -272,10 +279,11 @@ Phaser.Math = {
},
/**
* @method floorTo
* @method Phaser.Math#floorTo
* @param {number} value - The value to round.
* @param {number} place - The place to round to.
* @param {number} base - The base to round in... default is 10 for decimal.
* @return {number}
*/
floorTo: function (value, place, base) {
@@ -289,10 +297,11 @@ Phaser.Math = {
},
/**
* @method ceilTo
* @method Phaser.Math#ceilTo
* @param {number} value - The value to round.
* @param {number} place - The place to round to.
* @param {number} base - The base to round in... default is 10 for decimal.
* @return {number}
*/
ceilTo: function (value, place, base) {
@@ -307,10 +316,11 @@ Phaser.Math = {
/**
* A one dimensional linear interpolation of a value.
* @method interpolateFloat
* @method Phaser.Math#interpolateFloat
* @param {number} a
* @param {number} b
* @param {number} weight
* @return {number}
*/
interpolateFloat: function (a, b, weight) {
return (b - a) * weight + a;
@@ -318,11 +328,12 @@ Phaser.Math = {
/**
* Find the angle of a segment from (x1, y1) -> (x2, y2 ).
* @method angleBetween
* @method Phaser.Math#angleBetween
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @return {number}
*/
angleBetween: function (x1, y1, x2, y2) {
return Math.atan2(y2 - y1, x2 - x1);
@@ -330,9 +341,10 @@ Phaser.Math = {
/**
* Set an angle within the bounds of -&pi; to&pi;.
* @method normalizeAngle
* @method Phaser.Math#normalizeAngle
* @param {number} angle
* @param {boolean} radians - True if angle size is expressed in radians.
* @return {number}
*/
normalizeAngle: function (angle, radians) {
@@ -346,10 +358,11 @@ Phaser.Math = {
/**
* Closest angle between two angles from a1 to a2
* absolute value the return for exact angle
* @method nearestAngleBetween
* @method Phaser.Math#nearestAngleBetween
* @param {number} a1
* @param {number} a2
* @param {boolean} radians - True if angle sizes are expressed in radians.
* @return {number}
*/
nearestAngleBetween: function (a1, a2, radians) {
@@ -375,12 +388,13 @@ Phaser.Math = {
/**
* Interpolate across the shortest arc between two angles.
* @method interpolateAngles
* @method Phaser.Math#interpolateAngles
* @param {number} a1 - Description.
* @param {number} a2 - Description.
* @param {number} weight - Description.
* @param {boolean} radians - True if angle sizes are expressed in radians.
* @param {Description} ease - Description.
* @return {number}
*/
interpolateAngles: function (a1, a2, weight, radians, ease) {
@@ -400,7 +414,7 @@ Phaser.Math = {
* Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
* of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
* </p>
* @method chanceRoll
* @method Phaser.Math#chanceRoll
* @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).
* @return {boolean} True if the roll passed, or false otherwise.
*/
@@ -433,7 +447,7 @@ Phaser.Math = {
/**
* Returns an Array containing the numbers from min to max (inclusive).
*
* @method numberArray
* @method Phaser.Math#numberArray
* @param {number} min - The minimum value the array starts with.
* @param {number} max - The maximum value the array contains.
* @return {array} The array of number values.
@@ -454,11 +468,11 @@ Phaser.Math = {
/**
* Adds the given amount to the value, but never lets the value go over the specified maximum.
*
* @method maxAdd
* @method Phaser.Math#maxAdd
* @param {number} value - The value to add the amount to.
* @param {number} amount - The amount to add to the value.
* @param {number} max- The maximum the value is allowed to be.
* @return The new value.
* @return {number}
*/
maxAdd: function (value, amount, max) {
@@ -476,7 +490,7 @@ Phaser.Math = {
/**
* Subtracts the given amount from the value, but never lets the value go below the specified minimum.
*
* @method minSub
* @method Phaser.Math#minSub
* @param {number} value - The base value.
* @param {number} amount - The amount to subtract from the base value.
* @param {number} min - The minimum the value is allowed to be.
@@ -499,10 +513,11 @@ Phaser.Math = {
* Ensures that the value always stays between min and max, by wrapping the value around.
* <p>max should be larger than min, or the function will return 0</p>
*
* @method Phaser.Math#wrap
* @param value The value to wrap
* @param min The minimum the value is allowed to be
* @param max The maximum the value is allowed to be
* @return The wrapped value
* @return {number} The wrapped value
*/
wrap: function (value, min, max) {
@@ -523,12 +538,11 @@ Phaser.Math = {
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
* <p>Values must be positive integers, and are passed through Math.abs</p>
*
* @method wrapValue
* @method Phaser.Math#wrapValue
* @param {number} value - The value to add the amount to.
* @param {number} amount - The amount to add to the value.
* @param {number} max - The maximum the value is allowed to be.
* @return {number} The wrapped value.
*/
wrapValue: function (value, amount, max) {
@@ -545,7 +559,7 @@ Phaser.Math = {
/**
* Randomly returns either a 1 or -1.
*
* @method randomSign
* @method Phaser.Math#randomSign
* @return {number} 1 or -1
*/
randomSign: function () {
@@ -555,8 +569,8 @@ Phaser.Math = {
/**
* Returns true if the number given is odd.
*
* @method isOdd
* @param {number} n - The number to check.
* @method Phaser.Math#isOdd
* @param {number} n - The number to check.
* @return {boolean} True if the given number is odd. False if the given number is even.
*/
isOdd: function (n) {
@@ -568,8 +582,8 @@ Phaser.Math = {
/**
* Returns true if the number given is even.
*
* @method isEven
* @param {number} n - The number to check.
* @method Phaser.Math#isEven
* @param {number} n - The number to check.
* @return {boolean} True if the given number is even. False if the given number is odd.
*/
isEven: function (n) {
@@ -587,10 +601,10 @@ Phaser.Math = {
/**
* Significantly faster version of Math.max
* See {@link http://jsperf.com/math-s-min-max-vs-homemade/5}
* See http://jsperf.com/math-s-min-max-vs-homemade/5
*
* @method max
* @return The highest value from those given.
* @method Phaser.Math#max
* @return {number} The highest value from those given.
*/
max: function () {
@@ -608,10 +622,10 @@ Phaser.Math = {
/**
* Significantly faster version of Math.min
* See {@link http://jsperf.com/math-s-min-max-vs-homemade/5}
* See http://jsperf.com/math-s-min-max-vs-homemade/5
*
* @method min
* @return The lowest value from those given.
* @method Phaser.Math#min
* @return {number} The lowest value from those given.
*/
min: function () {
@@ -631,7 +645,7 @@ Phaser.Math = {
* Keeps an angle value between -180 and +180<br>
* Should be called whenever the angle is updated on the Sprite to stop it from going insane.
*
* @method wrapAngle
* @method Phaser.Math#wrapAngle
* @param {number} angle - The angle value to check
* @return {number} The new angle value, returns the same as the input angle if it was within bounds.
*/
@@ -660,7 +674,7 @@ Phaser.Math = {
/**
* Keeps an angle value between the given min and max values.
*
* @method angleLimit
* @method Phaser.Math#angleLimit
* @param {number} angle - The angle value to check. Must be between -180 and +180.
* @param {number} min - The minimum angle that is allowed (must be -180 or greater).
* @param {number} max - The maximum angle that is allowed (must be 180 or less).
@@ -679,7 +693,7 @@ Phaser.Math = {
/**
* Description.
* @method linearInterpolation
* @method Phaser.Math#linearInterpolation
* @param {number} v
* @param {number} k
* @return {number}
@@ -699,7 +713,7 @@ Phaser.Math = {
/**
* Description.
* @method bezierInterpolation
* @method Phaser.Math#bezierInterpolation
* @param {number} v
* @param {number} k
* @return {number}
@@ -715,7 +729,7 @@ Phaser.Math = {
/**
* Description.
* @method catmullRomInterpolation
* @method Phaser.Math#catmullRomInterpolation
* @param {number} v
* @param {number} k
* @return {number}
@@ -744,7 +758,7 @@ Phaser.Math = {
/**
* Description.
* @method Linear
* @method Phaser.Math#Linear
* @param {number} p0
* @param {number} p1
* @param {number} t
@@ -755,7 +769,7 @@ Phaser.Math = {
},
/**
* @method bernstein
* @method Phaser.Math#bernstein
* @param {number} n
* @param {number} i
* @return {number}
@@ -766,7 +780,7 @@ Phaser.Math = {
/**
* Description.
* @method catmullRom
* @method Phaser.Math#catmullRom
* @param {number} p0
* @param {number} p1
* @param {number} p2
@@ -779,6 +793,12 @@ Phaser.Math = {
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
},
/**
* @method Phaser.Math#difference
* @param {number} a
* @param {number} b
* @return {number}
*/
difference: function (a, b) {
return Math.abs(a - b);
},
@@ -787,11 +807,11 @@ Phaser.Math = {
* Fetch a random entry from the given array.
* Will return null if random selection is missing, or array has no entries.
*
* @method getRandom
* @param objects An array of objects.
* @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
* @param length Optional restriction on the number of values you want to randomly select from.
* @return The random object that was selected.
* @method Phaser.Math#getRandom
* @param {array} objects - An array of objects.
* @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array.
* @param {number} length - Optional restriction on the number of values you want to randomly select from.
* @return {object} The random object that was selected.
*/
getRandom: function (objects, startIndex, length) {
@@ -820,7 +840,7 @@ Phaser.Math = {
/**
* Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
*
* @method floor
* @method Phaser.Math#floor
* @param {number} Value Any number.
* @return {number} The rounded value of that number.
*/
@@ -835,9 +855,9 @@ Phaser.Math = {
/**
* Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
*
* @param Value Any number.
*
* @return The rounded value of that number.
* @method Phaser.Math#ceil
* @param {number} value - Any number.
* @return {number} The rounded value of that number.
*/
ceil: function (value) {
var n = value | 0;
@@ -850,13 +870,12 @@ Phaser.Math = {
* The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function
* you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time.
* </p>
* @param length The length of the wave
* @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
* @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
* @param frequency The frequency of the sine and cosine table data
* @return Returns the sine table
* @see getSinTable
* @see getCosTable
* @method Phaser.Math#sinCosGenerator
* @param {number} length - The length of the wave
* @param {number} sinAmplitude - The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
* @param {number} cosAmplitude - The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
* @param {number} frequency - The frequency of the sine and cosine table data
* @return {Array} Returns the sine table
*/
sinCosGenerator: function (length, sinAmplitude, cosAmplitude, frequency) {
@@ -887,9 +906,11 @@ Phaser.Math = {
/**
* Removes the top element from the stack and re-inserts it onto the bottom, then returns it.
* The original stack is modified in the process.
* This effectively moves the position of the data from the start to the end of the table.
* @return The value.
* The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table.
*
* @method Phaser.Math#shift
* @param {array} stack - The array to shift.
* @return {any} The shifted value.
*/
shift: function (stack) {
@@ -902,8 +923,9 @@ Phaser.Math = {
/**
* Shuffles the data in the given array into a new order
* @param array The array to shuffle
* @return The array
* @method Phaser.Math#shuffleArray
* @param {array} array - The array to shuffle
* @return {array} The array
*/
shuffleArray: function (array) {
@@ -922,7 +944,7 @@ Phaser.Math = {
/**
* Returns the distance between the two given set of coordinates.
*
* @method distance
* @method Phaser.Math#distance
* @param {number} x1
* @param {number} y1
* @param {number} x2
@@ -938,6 +960,16 @@ Phaser.Math = {
},
/**
* Returns the rounded distance between the two given set of coordinates.
*
* @method Phaser.Math#distanceRounded
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @return {number} The distance between this Point object and the destination Point object.
**/
distanceRounded: function (x1, y1, x2, y2) {
return Math.round(Phaser.Math.distance(x1, y1, x2, y2));
@@ -948,10 +980,11 @@ Phaser.Math = {
* Force a value within the boundaries of two values.
* Clamp value to range <a, b>
*
* @method clamp
* @method Phaser.Math#clamp
* @param {number} x
* @param {number} a
* @param {number} b
* @return {number}
*/
clamp: function ( x, a, b ) {
@@ -962,9 +995,10 @@ Phaser.Math = {
/**
* Clamp value to range <a, inf).
*
* @method clampBottom
* @method Phaser.Math#clampBottom
* @param {number} x
* @param {number} a
* @return {number}
*/
clampBottom: function ( x, a ) {
@@ -975,7 +1009,7 @@ Phaser.Math = {
/**
* Linear mapping from range <a1, a2> to range <b1, b2>
*
* @method mapLinear
* @method Phaser.Math#mapLinear
* @param {number} x
* @param {number} a1
* @param {number} a1
@@ -990,11 +1024,10 @@ Phaser.Math = {
},
//
/**
* {@link http://en.wikipedia.org/wiki/Smoothstep}
* Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
*
* @method smoothstep
* @method Phaser.Math#smoothstep
* @param {number} x
* @param {number} min
* @param {number} max
@@ -1012,9 +1045,9 @@ Phaser.Math = {
},
/**
* {@link http://en.wikipedia.org/wiki/Smoothstep}
* Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
*
* @method smootherstep
* @method Phaser.Math#smootherstep
* @param {number} x
* @param {number} min
* @param {number} max
@@ -1035,7 +1068,7 @@ Phaser.Math = {
* A value representing the sign of the value.
* -1 for negative, +1 for positive, 0 if value is 0
*
* @method sign
* @method Phaser.Math#sign
* @param {number} x
* @return {number}
*/
@@ -1048,7 +1081,7 @@ Phaser.Math = {
/**
* Convert degrees to radians.
*
* @method degToRad
* @method Phaser.Math#degToRad
* @return {function}
*/
degToRad: function() {
@@ -1066,7 +1099,7 @@ Phaser.Math = {
/**
* Convert degrees to radians.
*
* @method radToDeg
* @method Phaser.Math#radToDeg
* @return {function}
*/
radToDeg: function() {
+7 -11
View File
@@ -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.Quadtree
*/
/**
@@ -47,11 +46,8 @@
* QuadTree Constructor
*
* @class Phaser.QuadTree
* @classdesc Javascript QuadTree <p>
* The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
* it massively to add node indexing, removed lots of temp. var creation and significantly
* increased performance as a result.<p>
* Original version at {@link https://github.com/timohausmann/quadtree-js/}
* @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
* it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/
* @constructor
* @param {Description} physicsManager - Description.
* @param {Description} x - Description.
@@ -93,7 +89,7 @@ Phaser.QuadTree.prototype = {
/*
* Split the node into 4 subnodes
*
* @method split
* @method Phaser.QuadTree#split
*/
split: function() {
@@ -118,7 +114,7 @@ Phaser.QuadTree.prototype = {
* exceeds the capacity, it will split and add all
* objects to their corresponding subnodes.
*
* @method insert
* @method Phaser.QuadTree#insert
* @param {object} body - Description.
*/
insert: function (body) {
@@ -169,7 +165,7 @@ Phaser.QuadTree.prototype = {
/*
* Determine which node the object belongs to.
*
* @method getIndex
* @method Phaser.QuadTree#getIndex
* @param {object} rect - Description.
* @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.
*/
@@ -213,7 +209,7 @@ Phaser.QuadTree.prototype = {
/*
* Return all objects that could collide with the given object.
*
* @method retrieve
* @method Phaser.QuadTree#retrieve
* @param {object} rect - Description.
* @Return {array} - Array with all detected objects.
*/
@@ -249,7 +245,7 @@ Phaser.QuadTree.prototype = {
/*
* Clear the quadtree.
* @method clear
* @method Phaser.QuadTree#clear
*/
clear: function () {
+17 -19
View File
@@ -2,17 +2,15 @@
* @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.RandomDataGenerator
*/
/**
* Phaser.RandomDataGenerator constructor.
*
* @class Phaser.RandomDataGenerator
* @classdesc An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd
* Based on Nonsense by Josh Faul {@link https://github.com/jocafa/Nonsense}.
* Random number generator from {@link http://baagoe.org/en/wiki/Better_random_numbers_for_javascript}
* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense.
* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
*
* @constructor
* @param {array} seeds
@@ -53,7 +51,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Private random helper.
* @method rnd
* @method Phaser.RandomDataGenerator#rnd
* @private
* @return {number} Description.
*/
@@ -72,7 +70,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Reset the seed of the random data generator.
*
* @method sow
* @method Phaser.RandomDataGenerator#sow
* @param {array} seeds
*/
sow: function (seeds) {
@@ -98,7 +96,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Description.
* @method hash
* @method Phaser.RandomDataGenerator#hash
* @param {Any} data
* @private
* @return {number} Description.
@@ -126,7 +124,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random integer between 0 and 2^32.
* @method integer
* @method Phaser.RandomDataGenerator#integer
* @return {number}
*/
integer: function() {
@@ -135,7 +133,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random real number between 0 and 1.
* @method frac
* @method Phaser.RandomDataGenerator#frac
* @return {number}
*/
frac: function() {
@@ -144,7 +142,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random real number between 0 and 2^32.
* @method real
* @method Phaser.RandomDataGenerator#real
* @return {number}
*/
real: function() {
@@ -153,7 +151,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random integer between min and max.
* @method integerInRange
* @method Phaser.RandomDataGenerator#integerInRange
* @param {number} min
* @param {number} max
* @return {number}
@@ -164,7 +162,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random real number between min and max.
* @method realInRange
* @method Phaser.RandomDataGenerator#realInRange
* @param {number} min
* @param {number} max
* @return {number}
@@ -180,7 +178,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random real number between -1 and 1.
* @method normal
* @method Phaser.RandomDataGenerator#normal
* @return {number}
*/
normal: function () {
@@ -188,8 +186,8 @@ Phaser.RandomDataGenerator.prototype = {
},
/**
* Returns a valid RFC4122 version4 ID hex string (from {@link https://gist.github.com/1308368}).
* @method uuid
* Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
* @method Phaser.RandomDataGenerator#uuid
* @return {string}
*/
uuid: function () {
@@ -208,7 +206,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random member of `array`.
* @method pick
* @method Phaser.RandomDataGenerator#pick
* @param {Any} ary
* @return {number}
*/
@@ -218,7 +216,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random member of `array`, favoring the earlier entries.
* @method weightedPick
* @method Phaser.RandomDataGenerator#weightedPick
* @param {Any} ary
* @return {number}
*/
@@ -228,7 +226,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
* @method timestamp
* @method Phaser.RandomDataGenerator#timestamp
* @param {number} min
* @param {number} max
* @return {number}
@@ -239,7 +237,7 @@ Phaser.RandomDataGenerator.prototype = {
/**
* Returns a random angle between -180 and 180.
* @method angle
* @method Phaser.RandomDataGenerator#angle
* @return {number}
*/
angle: function() {