mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Tidying up source code for release. Also refactored World to use a Group instance, rather tha duplicate functions.
This commit is contained in:
+11
-25
@@ -456,7 +456,7 @@ Phaser.Input.prototype = {
|
||||
{
|
||||
return this.pointer1.move(event);
|
||||
}
|
||||
else if(this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.move(event);
|
||||
}
|
||||
@@ -487,7 +487,7 @@ Phaser.Input.prototype = {
|
||||
{
|
||||
return this.pointer1.stop(event);
|
||||
}
|
||||
else if(this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
|
||||
{
|
||||
return this.pointer2.stop(event);
|
||||
}
|
||||
@@ -520,7 +520,7 @@ Phaser.Input.prototype = {
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if(this.pointer2.active == state)
|
||||
else if (this.pointer2.active == state)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
@@ -551,7 +551,7 @@ Phaser.Input.prototype = {
|
||||
{
|
||||
return this.pointer1;
|
||||
}
|
||||
else if(this.pointer2.identifier == identifier)
|
||||
else if (this.pointer2.identifier == identifier)
|
||||
{
|
||||
return this.pointer2;
|
||||
}
|
||||
@@ -608,10 +608,8 @@ Object.defineProperty(Phaser.Input.prototype, "x", {
|
||||
|
||||
set: function (value) {
|
||||
this._x = Math.floor(value);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "y", {
|
||||
@@ -628,20 +626,16 @@ Object.defineProperty(Phaser.Input.prototype, "y", {
|
||||
|
||||
set: function (value) {
|
||||
this._y = Math.floor(value);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "pollLocked", {
|
||||
|
||||
get: function () {
|
||||
return (this.pollRate > 0 && this._pollCounter < this.pollRate);
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
|
||||
@@ -653,10 +647,8 @@ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
|
||||
**/
|
||||
get: function () {
|
||||
return 10 - this.currentPointers;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
||||
@@ -680,28 +672,22 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
||||
|
||||
return this.currentPointers;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldX", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.x + this.x;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldY", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.y + this.y;
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -611,10 +611,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", {
|
||||
|
||||
return this.game.time.now - this.timeDown;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
|
||||
@@ -627,10 +625,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
|
||||
|
||||
return this.game.world.camera.x + this.x;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
|
||||
@@ -643,8 +639,6 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
|
||||
|
||||
return this.game.world.camera.y + this.y;
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
+34
-18
@@ -19,6 +19,8 @@ Phaser.Touch = function (game) {
|
||||
this.touchLeaveCallback = null;
|
||||
this.touchCancelCallback = null;
|
||||
|
||||
this.preventDefault = true;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Touch.prototype = {
|
||||
@@ -73,30 +75,28 @@ Phaser.Touch.prototype = {
|
||||
return _this.onTouchCancel(event);
|
||||
};
|
||||
|
||||
this._documentTouchMove = function (event) {
|
||||
return _this.consumeTouchMove(event);
|
||||
};
|
||||
|
||||
this.game.renderer.view.addEventListener('touchstart', this._onTouchStart, false);
|
||||
this.game.renderer.view.addEventListener('touchmove', this._onTouchMove, false);
|
||||
this.game.renderer.view.addEventListener('touchend', this._onTouchEnd, false);
|
||||
this.game.renderer.view.addEventListener('touchenter', this._onTouchEnter, false);
|
||||
this.game.renderer.view.addEventListener('touchleave', this._onTouchLeave, false);
|
||||
this.game.renderer.view.addEventListener('touchcancel', this._onTouchCancel, false);
|
||||
|
||||
document.addEventListener('touchmove', this._documentTouchMove, false);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevent iOS bounce-back (doesn't work?)
|
||||
/**
|
||||
* Consumes all touchmove events on the document (only enable this if you know you need it!)
|
||||
* @method consumeTouchMove
|
||||
* @param {Any} event
|
||||
**/
|
||||
consumeTouchMove: function (event) {
|
||||
consumeDocumentTouches: function () {
|
||||
|
||||
event.preventDefault();
|
||||
this._documentTouchMove = function (event) {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
document.addEventListener('touchmove', this._documentTouchMove, false);
|
||||
|
||||
},
|
||||
|
||||
@@ -117,7 +117,10 @@ Phaser.Touch.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
|
||||
// event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
|
||||
@@ -147,7 +150,10 @@ Phaser.Touch.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
|
||||
// http://www.w3.org/TR/touch-events/#dfn-touchcancel
|
||||
@@ -176,7 +182,10 @@ Phaser.Touch.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
@@ -198,7 +207,10 @@ Phaser.Touch.prototype = {
|
||||
this.touchLeaveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
@@ -219,7 +231,10 @@ Phaser.Touch.prototype = {
|
||||
this.touchMoveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
@@ -240,7 +255,10 @@ Phaser.Touch.prototype = {
|
||||
this.touchEndCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if (this.preventDefault)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// For touch end its a list of the touch points that have been removed from the surface
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/TouchList
|
||||
@@ -266,8 +284,6 @@ Phaser.Touch.prototype = {
|
||||
this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter);
|
||||
this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave);
|
||||
this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel);
|
||||
|
||||
document.removeEventListener('touchmove', this._documentTouchMove);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user