You can now use the hitArea property on Sprites and Image objects. hitArea can be a geometry object (Rectangle, Circle, Polygon, Ellipse) and is used in pointerOver checks.

This commit is contained in:
photonstorm
2014-02-07 17:14:10 +00:00
parent 890e52008a
commit bc3a3fd43d
11 changed files with 417 additions and 18 deletions
+12 -2
View File
@@ -215,7 +215,7 @@ Phaser.InputHandler.prototype = {
this.enabled = true;
// Create the signals the Input component will emit
if (this.sprite.events && this.sprite.events.onInputOver == null)
if (this.sprite.events && this.sprite.events.onInputOver === null)
{
this.sprite.events.onInputOver = new Phaser.Signal();
this.sprite.events.onInputOut = new Phaser.Signal();
@@ -492,11 +492,18 @@ Phaser.InputHandler.prototype = {
*/
checkPointerOver: 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.parent.visible === false)
{
return false;
}
// Need to pass it a temp point, in case we need it again for the pixel check
if (this.game.input.hitTest(this.sprite, pointer))
{
return true;
}
/*
this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y);
if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height)
@@ -510,6 +517,9 @@ Phaser.InputHandler.prototype = {
return true;
}
}
*/
return false;
},