Updating all files to adhere to the JSHint settings and fixing lots of documentation errors on the way.

This commit is contained in:
photonstorm
2013-11-25 03:13:04 +00:00
parent 373b97648d
commit 13a2cc2feb
68 changed files with 4622 additions and 4628 deletions
+246 -247
View File
@@ -5,131 +5,129 @@
*/
/**
* Constructor for Phaser InputHandler.
* The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite.
* @class Phaser.InputHandler
* @classdesc Description.
* @constructor
* @param {Phaser.Sprite} game - Description.
* @param {Phaser.Sprite} sprite - The Sprite object to which this Input Handler belongs.
*/
Phaser.InputHandler = function (sprite) {
/**
* @property {Phaser.Sprite} sprite - Description.
*/
this.sprite = sprite;
/**
* @property {Phaser.Sprite} sprite - The Sprite object to which this Input Handler belongs.
*/
this.sprite = sprite;
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = sprite.game;
/**
* @property {boolean} enabled - Description.
* @default
*/
/**
* @property {boolean} enabled - If enabled the Input Handler will process input requests and monitor pointer activity.
* @default
*/
this.enabled = false;
// Linked list references
/**
* @property {Description} parent - Description.
* @default
*/
this.parent = null;
/**
* @property {Description} parent - Description.
* @default
*/
// this.parent = null;
/**
* @property {Description} next - Description.
* @default
*/
this.next = null;
/**
* @property {Description} next - Linked List
* @default
*/
// this.next = null;
/**
* @property {Description} prev - Description.
* @default
*/
this.prev = null;
/**
* @property {Description} prev - Description.
* @default
*/
// this.prev = null;
/**
* @property {Description} last - Description.
* @default
*/
this.last = this;
/**
* @property {Description} first - Description.
* @default
*/
this.first = this;
/**
* @property {Description} last - Description.
* @default
*/
// this.last = this;
/**
* @property {Description} first - Description.
* @default
*/
// this.first = this;
/**
* @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
* @default
*/
/**
* @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
* @default
*/
this.priorityID = 0;
/**
* @property {boolean} useHandCursor - Description.
* @default
*/
/**
* @property {boolean} useHandCursor - On a desktop browser you can set the 'hand' cursor to appear when moving over the Sprite.
* @default
*/
this.useHandCursor = false;
/**
* @property {boolean} isDragged - Description.
* @default
*/
/**
* @property {boolean} isDragged - true if the Sprite is being currently dragged.
* @default
*/
this.isDragged = false;
/**
* @property {boolean} allowHorizontalDrag - Description.
* @default
*/
/**
* @property {boolean} allowHorizontalDrag - Controls if the Sprite is allowed to be dragged horizontally.
* @default
*/
this.allowHorizontalDrag = true;
/**
* @property {boolean} allowVerticalDrag - Description.
* @default
*/
/**
* @property {boolean} allowVerticalDrag - Controls if the Sprite is allowed to be dragged vertically.
* @default
*/
this.allowVerticalDrag = true;
/**
* @property {boolean} bringToTop - Description.
* @default
*/
/**
* @property {boolean} bringToTop - If true when this Sprite is clicked or dragged it will automatically be bought to the top of the Group it is within.
* @default
*/
this.bringToTop = false;
/**
* @property {Description} snapOffset - Description.
* @default
*/
/**
* @property {Phaser.Point} snapOffset - A Point object that contains by how far the Sprite snap is offset.
* @default
*/
this.snapOffset = null;
/**
* @property {boolean} snapOnDrag - Description.
* @default
*/
/**
* @property {boolean} snapOnDrag - When the Sprite is dragged this controls if the center of the Sprite will snap to the pointer on drag or not.
* @default
*/
this.snapOnDrag = false;
/**
* @property {boolean} snapOnRelease - Description.
* @default
*/
/**
* @property {boolean} snapOnRelease - When the Sprite is dragged this controls if the Sprite will be snapped on release.
* @default
*/
this.snapOnRelease = false;
/**
* @property {number} snapX - Description.
* @default
*/
/**
* @property {number} snapX - When a Sprite has snapping enabled this holds the width of the snap grid.
* @default
*/
this.snapX = 0;
/**
* @property {number} snapY - Description.
* @default
*/
/**
* @property {number} snapY - When a Sprite has snapping enabled this holds the height of the snap grid.
* @default
*/
this.snapY = 0;
/**
* @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!
* @default
*/
/**
* @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!
* @default
*/
this.pixelPerfect = false;
/**
@@ -145,13 +143,13 @@ Phaser.InputHandler = function (sprite) {
this.draggable = false;
/**
* @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag.
* @property {Phaser.Rectangle} boundsRect - A region of the game world within which the sprite is restricted during drag.
* @default
*/
this.boundsRect = null;
/**
* @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag.
* @property {Phaser.Sprite} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag.
* @default
*/
this.boundsSprite = null;
@@ -168,7 +166,7 @@ Phaser.InputHandler = function (sprite) {
* @property {Phaser.Point} _tempPoint - Description.
* @private
*/
this._tempPoint = new Phaser.Point;
this._tempPoint = new Phaser.Point();
this._pointerData = [];
@@ -192,23 +190,23 @@ Phaser.InputHandler = function (sprite) {
Phaser.InputHandler.prototype = {
/**
* Description.
* @method Phaser.InputHandler#start
* @param {number} priority - Description.
* @param {boolean} useHandCursor - Description.
* @return {Phaser.Sprite} Description.
*/
start: function (priority, useHandCursor) {
/**
* Starts the Input Handler running. This is called automatically when you enable input on a Sprite, or can be called directly if you need to set a specific priority.
* @method Phaser.InputHandler#start
* @param {number} priority - Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other.
* @param {boolean} useHandCursor - If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers)
* @return {Phaser.Sprite} The Sprite object to which the Input Handler is bound.
*/
start: function (priority, useHandCursor) {
priority = priority || 0;
if (typeof useHandCursor == 'undefined') { useHandCursor = false; }
priority = priority || 0;
if (typeof useHandCursor == 'undefined') { useHandCursor = false; }
// Turning on
if (this.enabled == false)
if (this.enabled === false)
{
// Register, etc
this.game.input.interactiveItems.add(this);
this.game.input.interactiveItems.add(this);
this.useHandCursor = useHandCursor;
this.priorityID = priority;
@@ -231,29 +229,29 @@ Phaser.InputHandler.prototype = {
};
}
this.snapOffset = new Phaser.Point;
this.snapOffset = new Phaser.Point();
this.enabled = true;
// Create the signals the Input component will emit
if (this.sprite.events && this.sprite.events.onInputOver == null)
{
this.sprite.events.onInputOver = new Phaser.Signal;
this.sprite.events.onInputOut = new Phaser.Signal;
this.sprite.events.onInputDown = new Phaser.Signal;
this.sprite.events.onInputUp = new Phaser.Signal;
this.sprite.events.onDragStart = new Phaser.Signal;
this.sprite.events.onDragStop = new Phaser.Signal;
this.sprite.events.onInputOver = new Phaser.Signal();
this.sprite.events.onInputOut = new Phaser.Signal();
this.sprite.events.onInputDown = new Phaser.Signal();
this.sprite.events.onInputUp = new Phaser.Signal();
this.sprite.events.onDragStart = new Phaser.Signal();
this.sprite.events.onDragStop = new Phaser.Signal();
}
}
return this.sprite;
},
},
/**
* Description.
* @method Phaser.InputHandler#reset
*/
/**
* Resets the Input Handler and disables it.
* @method Phaser.InputHandler#reset
*/
reset: function () {
this.enabled = false;
@@ -278,14 +276,14 @@ Phaser.InputHandler.prototype = {
}
},
/**
* Description.
* @method Phaser.InputHandler#stop
*/
stop: function () {
/**
* Stops the Input Handler from running.
* @method Phaser.InputHandler#stop
*/
stop: function () {
// Turning off
if (this.enabled == false)
if (this.enabled === false)
{
return;
}
@@ -293,15 +291,15 @@ Phaser.InputHandler.prototype = {
{
// De-register, etc
this.enabled = false;
this.game.input.interactiveItems.remove(this);
this.game.input.interactiveItems.remove(this);
}
},
},
/**
* Clean up memory.
* @method Phaser.InputHandler#destroy
*/
/**
* Clean up memory.
* @method Phaser.InputHandler#destroy
*/
destroy: function () {
if (this.enabled)
@@ -310,99 +308,99 @@ Phaser.InputHandler.prototype = {
this.game.input.interactiveItems.remove(this);
this.stop();
this.stop();
this.sprite = null;
this.sprite = null;
}
},
/**
/**
* 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 Phaser.InputHandler#pointerX
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number} The x coordinate of the Input pointer.
*/
*/
pointerX: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].x;
},
/**
/**
* 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 Phaser.InputHandler#pointerY
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number} The y coordinate of the Input pointer.
*/
pointerY: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].y;
},
/**
/**
* If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
* @method Phaser.InputHandler#pointerDown
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {boolean}
*/
pointerDown: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].isDown;
},
/**
/**
* If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
* @method Phaser.InputHandler#pointerUp
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {boolean}
*/
pointerUp: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].isUp;
},
/**
/**
* A timestamp representing when the Pointer first touched the touchscreen.
* @method Phaser.InputHandler#pointerTimeDown
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number}
*/
pointerTimeDown: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].timeDown;
},
/**
/**
* A timestamp representing when the Pointer left the touchscreen.
* @method Phaser.InputHandler#pointerTimeUp
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number}
*/
pointerTimeUp: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].timeUp;
},
/**
/**
* Is the Pointer over this Sprite?
* @method Phaser.InputHandler#pointerOver
* @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.
@@ -432,13 +430,13 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Is the Pointer outside of this Sprite?
* @method Phaser.InputHandler#pointerOut
* @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.
* @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is out of this object.
*/
pointerOut: function (pointer) {
pointerOut: function (index) {
if (this.enabled)
{
@@ -462,52 +460,52 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* A timestamp representing when the Pointer first touched the touchscreen.
* @method Phaser.InputHandler#pointerTimeOver
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number}
*/
pointerTimeOver: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].timeOver;
},
/**
/**
* A timestamp representing when the Pointer left the touchscreen.
* @method Phaser.InputHandler#pointerTimeOut
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number}
*/
pointerTimeOut: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].timeOut;
},
/**
/**
* Is this sprite being dragged by the mouse or not?
* @method Phaser.InputHandler#pointerTimeOut
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number}
*/
pointerDragged: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
return this._pointerData[pointer].isDragged;
},
/**
/**
* Checks if the given pointer is over this Sprite.
* @method Phaser.InputHandler#checkPointerOver
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {boolean}
*/
checkPointerOver: function (pointer) {
@@ -533,7 +531,7 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to.
* It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true.
* @method Phaser.InputHandler#checkPixel
@@ -565,14 +563,14 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Update.
* @method Phaser.InputHandler#update
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
*/
update: function (pointer) {
if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false))
if (this.enabled === false || this.sprite.visible === false || (this.sprite.group && this.sprite.group.visible === false))
{
this._pointerOutHandler(pointer);
return false;
@@ -582,7 +580,7 @@ Phaser.InputHandler.prototype = {
{
return this.updateDrag(pointer);
}
else if (this._pointerData[pointer.id].isOver == true)
else if (this._pointerData[pointer.id].isOver === true)
{
if (this.checkPointerOver(pointer))
{
@@ -598,15 +596,15 @@ Phaser.InputHandler.prototype = {
}
},
/**
* Description.
* @method Phaser.InputHandler#_pointerOverHandler
* @private
* @param {Pointer} pointer
*/
/**
* Internal method handling the pointer over event.
* @method Phaser.InputHandler#_pointerOverHandler
* @private
* @param {Phaser.Pointer} pointer
*/
_pointerOverHandler: function (pointer) {
if (this._pointerData[pointer.id].isOver == false)
if (this._pointerData[pointer.id].isOver === false)
{
this._pointerData[pointer.id].isOver = true;
this._pointerData[pointer.id].isOut = false;
@@ -614,7 +612,7 @@ Phaser.InputHandler.prototype = {
this._pointerData[pointer.id].x = pointer.x - this.sprite.x;
this._pointerData[pointer.id].y = pointer.y - this.sprite.y;
if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false)
{
this.game.stage.canvas.style.cursor = "pointer";
}
@@ -623,19 +621,19 @@ Phaser.InputHandler.prototype = {
}
},
/**
* Description.
* @method Phaser.InputHandler#_pointerOutHandler
* @private
* @param {Pointer} pointer
*/
/**
* Internal method handling the pointer out event.
* @method Phaser.InputHandler#_pointerOutHandler
* @private
* @param {Phaser.Pointer} pointer
*/
_pointerOutHandler: function (pointer) {
this._pointerData[pointer.id].isOver = false;
this._pointerData[pointer.id].isOut = true;
this._pointerData[pointer.id].timeOut = this.game.time.now;
if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false)
{
this.game.stage.canvas.style.cursor = "default";
}
@@ -647,15 +645,15 @@ Phaser.InputHandler.prototype = {
},
/**
* Description.
* @method Phaser.InputHandler#_touchedHandler
* @private
* @param {Pointer} pointer
*/
/**
* Internal method handling the touched event.
* @method Phaser.InputHandler#_touchedHandler
* @private
* @param {Phaser.Pointer} pointer
*/
_touchedHandler: function (pointer) {
if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true)
if (this._pointerData[pointer.id].isDown === false && this._pointerData[pointer.id].isOver === true)
{
this._pointerData[pointer.id].isDown = true;
this._pointerData[pointer.id].isUp = false;
@@ -663,7 +661,7 @@ Phaser.InputHandler.prototype = {
this.sprite.events.onInputDown.dispatch(this.sprite, pointer);
// Start drag
if (this.draggable && this.isDragged == false)
if (this.draggable && this.isDragged === false)
{
this.startDrag(pointer);
}
@@ -671,7 +669,7 @@ Phaser.InputHandler.prototype = {
if (this.bringToTop)
{
this.sprite.bringToTop();
}
}
}
// Consume the event?
@@ -679,12 +677,12 @@ Phaser.InputHandler.prototype = {
},
/**
* Description.
* @method Phaser.InputHandler#_releasedHandler
* @private
* @param {Pointer} pointer
*/
/**
* Internal method handling the pointer released event.
* @method Phaser.InputHandler#_releasedHandler
* @private
* @param {Phaser.Pointer} pointer
*/
_releasedHandler: function (pointer) {
// If was previously touched by this Pointer, check if still is AND still over this item
@@ -719,10 +717,10 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Updates the Pointer drag on this Sprite.
* @method Phaser.InputHandler#updateDrag
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {boolean}
*/
updateDrag: function (pointer) {
@@ -763,79 +761,79 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method Phaser.InputHandler#justOver
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just over.
* @return {boolean}
*/
justOver: function (pointer, delay) {
pointer = pointer || 0;
delay = delay || 500;
pointer = pointer || 0;
delay = delay || 500;
return (this._pointerData[pointer].isOver && this.overDuration(pointer) < delay);
},
/**
/**
* Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method Phaser.InputHandler#justOut
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just out.
* @return {boolean}
*/
justOut: function (pointer, delay) {
pointer = pointer || 0;
delay = delay || 500;
pointer = pointer || 0;
delay = delay || 500;
return (this._pointerData[pointer].isOut && (this.game.time.now - this._pointerData[pointer].timeOut < delay));
},
/**
/**
* Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method Phaser.InputHandler#justPressed
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just over.
* @return {boolean}
*/
justPressed: function (pointer, delay) {
pointer = pointer || 0;
delay = delay || 500;
pointer = pointer || 0;
delay = delay || 500;
return (this._pointerData[pointer].isDown && this.downDuration(pointer) < delay);
},
/**
/**
* Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
* @method Phaser.InputHandler#justReleased
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @param {number} delay - The time below which the pointer is considered as just out.
* @return {boolean}
*/
justReleased: function (pointer, delay) {
pointer = pointer || 0;
delay = delay || 500;
pointer = pointer || 0;
delay = delay || 500;
return (this._pointerData[pointer].isUp && (this.game.time.now - this._pointerData[pointer].timeUp < delay));
},
/**
/**
* If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
* @method Phaser.InputHandler#overDuration
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over.
*/
overDuration: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
if (this._pointerData[pointer].isOver)
{
@@ -846,15 +844,15 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
* @method Phaser.InputHandler#downDuration
* @param {Pointer} pointer
* @param {Phaser.Pointer} pointer
* @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.
*/
downDuration: function (pointer) {
pointer = pointer || 0;
pointer = pointer || 0;
if (this._pointerData[pointer].isDown)
{
@@ -865,25 +863,24 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
* @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.
* @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)
* @param boundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere
* @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
* @param {boolean} [lockCenter=false] - 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 {boolean} [bringToTop=false] - If true the Sprite will be bought to the top of the rendering list in its current Group.
* @param {boolean} [pixelPerfect=false] - If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.
* @param {boolean} [alphaThreshold=255] - If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed.
* @param {Phaser.Rectangle} [boundsRect=null] - If you want to restrict the drag of this sprite to a specific Rectangle, pass the Phaser.Rectangle here, otherwise it's free to drag anywhere.
* @param {Phaser.Sprite} [boundsSprite=null] - If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here.
*/
enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) {
if (typeof lockCenter == 'undefined') { lockCenter = false; }
if (typeof bringToTop == 'undefined') { bringToTop = false; }
if (typeof pixelPerfect == 'undefined') { pixelPerfect = false; }
alphaThreshold = alphaThreshold || 255;
boundsRect = boundsRect || null;
boundsSprite = boundsSprite || null;
if (typeof alphaThreshold == 'undefined') { alphaThreshold = 255; }
if (typeof boundsRect == 'undefined') { boundsRect = null; }
if (typeof boundsSprite == 'undefined') { boundsSprite = null; }
this._dragPoint = new Phaser.Point();
this.draggable = true;
@@ -906,7 +903,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 Phaser.InputHandler#disableDrag
*/
@@ -926,9 +923,10 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
* @method Phaser.InputHandler#startDrag
* @param {Phaser.Pointer} pointer
*/
startDrag: function (pointer) {
@@ -957,9 +955,10 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
* @method Phaser.InputHandler#stopDrag
* @param {Phaser.Pointer} pointer
*/
stopDrag: function (pointer) {
@@ -976,37 +975,37 @@ Phaser.InputHandler.prototype = {
this.sprite.events.onDragStop.dispatch(this.sprite, pointer);
this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
if (this.checkPointerOver(pointer) == false)
if (this.checkPointerOver(pointer) === false)
{
this._pointerOutHandler(pointer);
}
},
/**
/**
* Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!
* @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
* @param {boolean} [allowHorizontal=true] - To enable the sprite to be dragged horizontally set to true, otherwise false.
* @param {boolean} [allowVertical=true] - To enable the sprite to be dragged vertically set to true, otherwise false.
*/
setDragLock: function (allowHorizontal, allowVertical) {
if (typeof allowHorizontal == 'undefined') { allowHorizontal = true; }
if (typeof allowVertical == 'undefined') { allowVertical = true; }
if (typeof allowVertical == 'undefined') { allowVertical = true; }
this.allowHorizontalDrag = allowHorizontal;
this.allowVerticalDrag = allowVertical;
},
/**
/**
* 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 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
* @param onRelease If true the sprite will snap to the grid when released
* @param {number} snapX - The width of the grid cell to snap to.
* @param {number} snapY - The height of the grid cell to snap to.
* @param {boolean} [onDrag=true] - If true the sprite will snap to the grid while being dragged.
* @param {boolean} [onRelease=false] - If true the sprite will snap to the grid when released.
*/
enableSnap: function (snapX, snapY, onDrag, onRelease) {
@@ -1020,7 +1019,7 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Stops the sprite from snapping to a grid during drag or release.
* @method Phaser.InputHandler#disableSnap
*/
@@ -1031,7 +1030,7 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Bounds Rect check for the sprite drag
* @method Phaser.InputHandler#checkBoundsRect
*/
@@ -1057,7 +1056,7 @@ Phaser.InputHandler.prototype = {
},
/**
/**
* Parent Sprite Bounds check for the sprite drag.
* @method Phaser.InputHandler#checkBoundsSprite
*/