Skip to content

Commit

Permalink
Added multitouch support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eemeli Kelokorpi committed Apr 2, 2014
1 parent fa1dbda commit 9ecf5e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/engine/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(typeof(global) !== 'undefined' && global.game) return;
@class Core
**/
var core = {
version: '1.2.1',
version: '1.3.0',
config: window.pandaConfig || {},
/**
Scale factor for Retina and HiRes mode.
Expand Down
32 changes: 12 additions & 20 deletions src/engine/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3659,14 +3659,12 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
touchData.global.x = touchEvent.clientX;
touchData.global.y = touchEvent.clientY;
}
}

var length = this.interactiveItems.length;
for (i = 0; i < length; i++)
{
var item = this.interactiveItems[i];
if(item.touchmove)
item.touchmove(touchData);
for (var j = 0; j < this.interactiveItems.length; j++)
{
var item = this.interactiveItems[j];
if(item.touchmove && item.__touchDatas[touchEvent.identifier]) item.touchmove(touchData);
}
}
};

Expand Down Expand Up @@ -3716,7 +3714,8 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
//call the function!
if(item.touchstart)item.touchstart(touchData);
item.__isDown = true;
item.__touchData = touchData;
item.__touchDatas = item.__touchDatas || {};
item.__touchDatas[touchEvent.identifier] = touchData;

if(!item.interactiveChildren)break;
}
Expand Down Expand Up @@ -3754,11 +3753,11 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
for (var j = 0; j < length; j++)
{
var item = this.interactiveItems[j];
var itemTouchData = item.__touchData; // <-- Here!
item.__hit = this.hitTest(item, touchData);

if(itemTouchData === touchData)
{
if(item.__touchDatas[touchEvent.identifier]) {

item.__hit = this.hitTest(item, item.__touchDatas[touchEvent.identifier]);

// so this one WAS down...
touchData.originalEvent = event || window.event;
// hitTest??
Expand Down Expand Up @@ -3786,15 +3785,8 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
item.__isDown = false;
}

item.__touchData = null;

}
/*
else
{
item.__touchDatas[touchEvent.identifier] = null;
}
*/
}
// remove the touch..
this.pool.push(touchData);
Expand Down
2 changes: 1 addition & 1 deletion src/game/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ game.module(
game.addAsset('logo.png');

SceneGame = game.Scene.extend({
backgroundColor: 0x808080,
backgroundColor: 0xb9bec7,

init: function() {
var logo = new game.Sprite('logo.png');
Expand Down

0 comments on commit 9ecf5e2

Please sign in to comment.