Updated to Pixi 1.5 final.

InputHandler.pixelPerfectOver - performs a pixel perfect check to see if any pointer is over the current object (warning: very expensive!)
InputHandler.pixelPerfectClick - performs a pixel perfect check but only when the pointer touches/clicks on the current object.
This commit is contained in:
photonstorm
2014-02-12 01:25:36 +00:00
parent da878b2181
commit ab5c07dfe8
46 changed files with 845 additions and 526 deletions
+14 -8
View File
@@ -225,12 +225,12 @@ Phaser.Pointer.prototype = {
this._holdSent = false;
// This sets the x/y and other local values
this.move(event);
this.move(event, true);
// x and y are the old values here?
this.positionDown.setTo(this.x, this.y);
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
if (this.game.input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
{
this.game.input.x = this.x;
this.game.input.y = this.y;
@@ -242,7 +242,7 @@ Phaser.Pointer.prototype = {
this._stateReset = false;
this.totalTouches++;
if (this.isMouse === false)
if (!this.isMouse)
{
this.game.input.currentPointers++;
}
@@ -297,14 +297,17 @@ Phaser.Pointer.prototype = {
* Called when the Pointer is moved.
* @method Phaser.Pointer#move
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
* @param {boolean} [fromClick=false] - Was this called from the click event?
*/
move: function (event) {
move: function (event, fromClick) {
if (this.game.input.pollLocked)
{
return;
}
if (typeof fromClick === 'undefined') { fromClick = false; }
if (typeof event.button !== 'undefined')
{
this.button = event.button;
@@ -371,11 +374,14 @@ Phaser.Pointer.prototype = {
do
{
// If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
if (currentNode.pixelPerfect || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID == this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))
if (currentNode.pixelPerfectClick || currentNode.pixelPerfectOver || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID === this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))
{
if (currentNode.checkPointerOver(this))
if ((!fromClick && currentNode.checkPointerOver(this)) || (fromClick && currentNode.checkPointerDown(this)))
{
// console.log('HRO set', currentNode.sprite.name);
if (fromClick)
{
console.log('HRO set', currentNode.sprite.name, currentNode.priorityID, 'current highest', this._highestRenderOrderID, 'highest p', this._highestInputPriorityID);
}
this._highestRenderOrderID = currentNode.sprite.renderOrderID;
this._highestInputPriorityID = currentNode.priorityID;
this._highestRenderObject = currentNode;
@@ -443,7 +449,7 @@ Phaser.Pointer.prototype = {
leave: function (event) {
this.withinGame = false;
this.move(event);
this.move(event, false);
},