mirror of
https://github.com/wassname/phaser.git
synced 2026-07-07 00:06:37 +08:00
Updated doc files.
This commit is contained in:
+206
-120
@@ -90,6 +90,10 @@
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
@@ -162,6 +166,14 @@
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
@@ -186,6 +198,10 @@
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
@@ -278,6 +294,10 @@
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
@@ -342,6 +362,10 @@
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -374,36 +398,6 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#bottom">bottom</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#render">render</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#renderXY">renderXY</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#right">right</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -423,7 +417,7 @@
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
@@ -451,36 +445,6 @@ Phaser.InputHandler = function (sprite) {
|
||||
*/
|
||||
this.enabled = false;
|
||||
|
||||
/**
|
||||
* @property {Description} parent - Description.
|
||||
* @default
|
||||
*/
|
||||
// this.parent = null;
|
||||
|
||||
/**
|
||||
* @property {Description} next - Linked List
|
||||
* @default
|
||||
*/
|
||||
// this.next = 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 {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
|
||||
* @default
|
||||
@@ -547,6 +511,18 @@ Phaser.InputHandler = function (sprite) {
|
||||
*/
|
||||
this.snapY = 0;
|
||||
|
||||
/**
|
||||
* @property {number} snapOffsetX - This defines the top-left X coordinate of the snap grid.
|
||||
* @default
|
||||
*/
|
||||
this.snapOffsetX = 0;
|
||||
|
||||
/**
|
||||
* @property {number} snapOffsetY - This defines the top-left Y coordinate of the snap grid..
|
||||
* @default
|
||||
*/
|
||||
this.snapOffsetY = 0;
|
||||
|
||||
/**
|
||||
* @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!
|
||||
* @default
|
||||
@@ -622,8 +598,6 @@ Phaser.InputHandler.prototype = {
|
||||
*/
|
||||
start: function (priority, useHandCursor) {
|
||||
|
||||
console.log('InputHandler start');
|
||||
|
||||
priority = priority || 0;
|
||||
if (typeof useHandCursor == 'undefined') { useHandCursor = false; }
|
||||
|
||||
@@ -1039,7 +1013,7 @@ Phaser.InputHandler.prototype = {
|
||||
|
||||
if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false)
|
||||
{
|
||||
this.game.stage.canvas.style.cursor = "pointer";
|
||||
this.game.canvas.style.cursor = "pointer";
|
||||
}
|
||||
|
||||
this.sprite.events.onInputOver.dispatch(this.sprite, pointer);
|
||||
@@ -1060,7 +1034,7 @@ Phaser.InputHandler.prototype = {
|
||||
|
||||
if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false)
|
||||
{
|
||||
this.game.stage.canvas.style.cursor = "default";
|
||||
this.game.canvas.style.cursor = "default";
|
||||
}
|
||||
|
||||
if (this.sprite && this.sprite.events)
|
||||
@@ -1121,15 +1095,18 @@ Phaser.InputHandler.prototype = {
|
||||
// Only release the InputUp signal if the pointer is still over this sprite
|
||||
if (this.checkPointerOver(pointer))
|
||||
{
|
||||
//console.log('releasedHandler: ' + Date.now());
|
||||
this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
|
||||
// Release the inputUp signal and provide optional parameter if pointer is still over the sprite or not
|
||||
this.sprite.events.onInputUp.dispatch(this.sprite, pointer, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Release the inputUp signal and provide optional parameter if pointer is still over the sprite or not
|
||||
this.sprite.events.onInputUp.dispatch(this.sprite, pointer, false);
|
||||
|
||||
// Pointer outside the sprite? Reset the cursor
|
||||
if (this.useHandCursor)
|
||||
{
|
||||
this.game.stage.canvas.style.cursor = "default";
|
||||
this.game.canvas.style.cursor = "default";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,30 +1133,61 @@ Phaser.InputHandler.prototype = {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.allowHorizontalDrag)
|
||||
if (this.sprite.fixedToCamera)
|
||||
{
|
||||
this.sprite.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
|
||||
}
|
||||
if (this.allowHorizontalDrag)
|
||||
{
|
||||
this.sprite.cameraOffset.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
|
||||
}
|
||||
|
||||
if (this.allowVerticalDrag)
|
||||
{
|
||||
this.sprite.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
|
||||
}
|
||||
if (this.allowVerticalDrag)
|
||||
{
|
||||
this.sprite.cameraOffset.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
|
||||
}
|
||||
|
||||
if (this.boundsRect)
|
||||
{
|
||||
this.checkBoundsRect();
|
||||
}
|
||||
if (this.boundsRect)
|
||||
{
|
||||
this.checkBoundsRect();
|
||||
}
|
||||
|
||||
if (this.boundsSprite)
|
||||
{
|
||||
this.checkBoundsSprite();
|
||||
}
|
||||
if (this.boundsSprite)
|
||||
{
|
||||
this.checkBoundsSprite();
|
||||
}
|
||||
|
||||
if (this.snapOnDrag)
|
||||
if (this.snapOnDrag)
|
||||
{
|
||||
this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
|
||||
this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
|
||||
if (this.allowHorizontalDrag)
|
||||
{
|
||||
this.sprite.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
|
||||
}
|
||||
|
||||
if (this.allowVerticalDrag)
|
||||
{
|
||||
this.sprite.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
|
||||
}
|
||||
|
||||
if (this.boundsRect)
|
||||
{
|
||||
this.checkBoundsRect();
|
||||
}
|
||||
|
||||
if (this.boundsSprite)
|
||||
{
|
||||
this.checkBoundsSprite();
|
||||
}
|
||||
|
||||
if (this.snapOnDrag)
|
||||
{
|
||||
this.sprite.x = Math.round((this.sprite.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.y = Math.round((this.sprite.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1359,14 +1367,29 @@ Phaser.InputHandler.prototype = {
|
||||
this._draggedPointerID = pointer.id;
|
||||
this._pointerData[pointer.id].isDragged = true;
|
||||
|
||||
if (this.dragFromCenter)
|
||||
if (this.sprite.fixedToCamera)
|
||||
{
|
||||
this.sprite.centerOn(pointer.x, pointer.y);
|
||||
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
|
||||
if (this.dragFromCenter)
|
||||
{
|
||||
this.sprite.centerOn(pointer.x, pointer.y);
|
||||
this._dragPoint.setTo(this.sprite.cameraOffset.x - pointer.x, this.sprite.cameraOffset.y - pointer.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._dragPoint.setTo(this.sprite.cameraOffset.x - pointer.x, this.sprite.cameraOffset.y - pointer.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
|
||||
if (this.dragFromCenter)
|
||||
{
|
||||
this.sprite.centerOn(pointer.x, pointer.y);
|
||||
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateDrag(pointer);
|
||||
@@ -1393,8 +1416,16 @@ Phaser.InputHandler.prototype = {
|
||||
|
||||
if (this.snapOnRelease)
|
||||
{
|
||||
this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
|
||||
this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
|
||||
if (this.sprite.fixedToCamera)
|
||||
{
|
||||
this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sprite.x = Math.round((this.sprite.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.y = Math.round((this.sprite.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
}
|
||||
}
|
||||
|
||||
this.sprite.events.onDragStop.dispatch(this.sprite, pointer);
|
||||
@@ -1431,14 +1462,20 @@ Phaser.InputHandler.prototype = {
|
||||
* @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.
|
||||
* @param {number} [snapOffsetX=0] - Used to offset the top-left starting point of the snap grid.
|
||||
* @param {number} [snapOffsetX=0] - Used to offset the top-left starting point of the snap grid.
|
||||
*/
|
||||
enableSnap: function (snapX, snapY, onDrag, onRelease) {
|
||||
enableSnap: function (snapX, snapY, onDrag, onRelease, snappOffsetX, snappOffsetY) {
|
||||
|
||||
if (typeof onDrag == 'undefined') { onDrag = true; }
|
||||
if (typeof onRelease == 'undefined') { onRelease = false; }
|
||||
if (typeof snapOffsetX == 'undefined') { snapOffsetX = 0; }
|
||||
if (typeof snapOffsetY == 'undefined') { snapOffsetY = 0; }
|
||||
|
||||
this.snapX = snapX;
|
||||
this.snapY = snapY;
|
||||
this.snapOffsetX = snapOffsetX;
|
||||
this.snapOffsetY = snapOffsetY;
|
||||
this.snapOnDrag = onDrag;
|
||||
this.snapOnRelease = onRelease;
|
||||
|
||||
@@ -1461,22 +1498,45 @@ Phaser.InputHandler.prototype = {
|
||||
*/
|
||||
checkBoundsRect: function () {
|
||||
|
||||
if (this.sprite.x < this.boundsRect.left)
|
||||
if (this.sprite.fixedToCamera)
|
||||
{
|
||||
this.sprite.x = this.boundsRect.x;
|
||||
}
|
||||
else if ((this.sprite.x + this.sprite.width) > this.boundsRect.right)
|
||||
{
|
||||
this.sprite.x = this.boundsRect.right - this.sprite.width;
|
||||
}
|
||||
if (this.sprite.cameraOffset.x < this.boundsRect.left)
|
||||
{
|
||||
this.sprite.cameraOffset.x = this.boundsRect.cameraOffset.x;
|
||||
}
|
||||
else if ((this.sprite.cameraOffset.x + this.sprite.width) > this.boundsRect.right)
|
||||
{
|
||||
this.sprite.cameraOffset.x = this.boundsRect.right - this.sprite.width;
|
||||
}
|
||||
|
||||
if (this.sprite.y < this.boundsRect.top)
|
||||
{
|
||||
this.sprite.y = this.boundsRect.top;
|
||||
if (this.sprite.cameraOffset.y < this.boundsRect.top)
|
||||
{
|
||||
this.sprite.cameraOffset.y = this.boundsRect.top;
|
||||
}
|
||||
else if ((this.sprite.cameraOffset.y + this.sprite.height) > this.boundsRect.bottom)
|
||||
{
|
||||
this.sprite.cameraOffset.y = this.boundsRect.bottom - this.sprite.height;
|
||||
}
|
||||
}
|
||||
else if ((this.sprite.y + this.sprite.height) > this.boundsRect.bottom)
|
||||
else
|
||||
{
|
||||
this.sprite.y = this.boundsRect.bottom - this.sprite.height;
|
||||
if (this.sprite.x < this.boundsRect.left)
|
||||
{
|
||||
this.sprite.x = this.boundsRect.x;
|
||||
}
|
||||
else if ((this.sprite.x + this.sprite.width) > this.boundsRect.right)
|
||||
{
|
||||
this.sprite.x = this.boundsRect.right - this.sprite.width;
|
||||
}
|
||||
|
||||
if (this.sprite.y < this.boundsRect.top)
|
||||
{
|
||||
this.sprite.y = this.boundsRect.top;
|
||||
}
|
||||
else if ((this.sprite.y + this.sprite.height) > this.boundsRect.bottom)
|
||||
{
|
||||
this.sprite.y = this.boundsRect.bottom - this.sprite.height;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
@@ -1487,27 +1547,53 @@ Phaser.InputHandler.prototype = {
|
||||
*/
|
||||
checkBoundsSprite: function () {
|
||||
|
||||
if (this.sprite.x < this.boundsSprite.x)
|
||||
if (this.sprite.fixedToCamera && this.boundsSprite.fixedToCamera)
|
||||
{
|
||||
this.sprite.x = this.boundsSprite.x;
|
||||
}
|
||||
else if ((this.sprite.x + this.sprite.width) > (this.boundsSprite.x + this.boundsSprite.width))
|
||||
{
|
||||
this.sprite.x = (this.boundsSprite.x + this.boundsSprite.width) - this.sprite.width;
|
||||
}
|
||||
if (this.sprite.cameraOffset.x < this.boundsSprite.camerOffset.x)
|
||||
{
|
||||
this.sprite.cameraOffset.x = this.boundsSprite.camerOffset.x;
|
||||
}
|
||||
else if ((this.sprite.cameraOffset.x + this.sprite.width) > (this.boundsSprite.camerOffset.x + this.boundsSprite.width))
|
||||
{
|
||||
this.sprite.cameraOffset.x = (this.boundsSprite.camerOffset.x + this.boundsSprite.width) - this.sprite.width;
|
||||
}
|
||||
|
||||
if (this.sprite.y < this.boundsSprite.y)
|
||||
{
|
||||
this.sprite.y = this.boundsSprite.y;
|
||||
if (this.sprite.cameraOffset.y < this.boundsSprite.camerOffset.y)
|
||||
{
|
||||
this.sprite.cameraOffset.y = this.boundsSprite.camerOffset.y;
|
||||
}
|
||||
else if ((this.sprite.cameraOffset.y + this.sprite.height) > (this.boundsSprite.camerOffset.y + this.boundsSprite.height))
|
||||
{
|
||||
this.sprite.cameraOffset.y = (this.boundsSprite.camerOffset.y + this.boundsSprite.height) - this.sprite.height;
|
||||
}
|
||||
}
|
||||
else if ((this.sprite.y + this.sprite.height) > (this.boundsSprite.y + this.boundsSprite.height))
|
||||
else
|
||||
{
|
||||
this.sprite.y = (this.boundsSprite.y + this.boundsSprite.height) - this.sprite.height;
|
||||
if (this.sprite.x < this.boundsSprite.x)
|
||||
{
|
||||
this.sprite.x = this.boundsSprite.x;
|
||||
}
|
||||
else if ((this.sprite.x + this.sprite.width) > (this.boundsSprite.x + this.boundsSprite.width))
|
||||
{
|
||||
this.sprite.x = (this.boundsSprite.x + this.boundsSprite.width) - this.sprite.width;
|
||||
}
|
||||
|
||||
if (this.sprite.y < this.boundsSprite.y)
|
||||
{
|
||||
this.sprite.y = this.boundsSprite.y;
|
||||
}
|
||||
else if ((this.sprite.y + this.sprite.height) > (this.boundsSprite.y + this.boundsSprite.height))
|
||||
{
|
||||
this.sprite.y = (this.boundsSprite.y + this.boundsSprite.height) - this.sprite.height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};</pre>
|
||||
};
|
||||
|
||||
Phaser.InputHandler.prototype.constructor = Phaser.InputHandler;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -1522,13 +1608,13 @@ Phaser.InputHandler.prototype = {
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2013 Photon Storm Ltd.
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Wed Feb 05 2014 06:28:24 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user