Skip to content

Commit

Permalink
Added support for sprite touchover() and touchout()
Browse files Browse the repository at this point in the history
  • Loading branch information
Eemeli Kelokorpi committed Mar 8, 2014
1 parent ee3ad72 commit bf7e272
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/engine/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2913,6 +2913,7 @@ PIXI.InteractionManager = function(stage)
* @type InteractionData
*/
this.mouse = new PIXI.InteractionData();
this.mouse.global.x = this.mouse.global.y = -10000;

/**
* an object that stores current touches (InteractionData) by id reference
Expand Down Expand Up @@ -3180,7 +3181,8 @@ PIXI.InteractionManager.prototype.update = function()

if(!item.__isOver)
{
if(item.mouseover)item.mouseover(this.mouse);
if(item.mouseover) item.mouseover(this.mouse);
else if(item.touchover) item.touchover(this.mouse);
item.__isOver = true;
}
}
Expand All @@ -3190,6 +3192,7 @@ PIXI.InteractionManager.prototype.update = function()
{
// roll out!
if(item.mouseout)item.mouseout(this.mouse);
else if(item.touchout) item.touchout(this.mouse);
item.__isOver = false;
}
}
Expand Down Expand Up @@ -3365,6 +3368,7 @@ PIXI.InteractionManager.prototype.onMouseUp = function(event)
PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
{
var global = interactionData.global;
if(global.x === -10000 && global.y === -10000) return false;

if( !item.worldVisible )return false;

Expand Down Expand Up @@ -3456,6 +3460,8 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
touchData.global.x = touchEvent.clientX;
touchData.global.y = touchEvent.clientY;
}
this.mouse.global.x = touchData.global.x;
this.mouse.global.y = touchData.global.y;
}

var length = this.interactiveItems.length;
Expand Down

0 comments on commit bf7e272

Please sign in to comment.