CUCHO Posted April 24, 2015 Share Posted April 24, 2015 Hello everyone.I am trying to use the touch events in PIXI and I do not know how to get the local position of each finger, I have this:stage = new PIXI.Container (); // general containerspriteParent = new PIXI.sprite (texture); // for transformsspriteChild = new PIXI.sprite (texture); // for transformsspriteParent.addChild (spriteChild);stage.addChild (spriteParent);stage.touchstart = function (event) { // for two fingers var point = event.data.getLocalPosition (spriteParent); // this give me the local position for one finger relative to spriteParent coordinates var finger_1_x = event.data.originalEvent.touches[0].pageX; // these give me the position for two fingers var finger_1_y = event.data.originalEvent.touches[0].pageY; // but how I get the local position for those? var finger_2_x = event.data.originalEvent.touches[1].pageX; var finger_2_y = event.data.originalEvent.touches[1].pageY; };Thanks Quote Link to comment Share on other sites More sharing options...
clement_cvL Posted April 24, 2015 Share Posted April 24, 2015 Hey! I didn't have time to test, put can you try to pass the touch location in the getLocalPosition ?var pt = new PIXI.Point(event.data.originalEvent.touches[0].clientX, event.data.originalEvent.touches[0].clientY);var localPt = event.data.getLocalPosition(spriteParent, pt);If it's not working (probably), you can always create your own touches manager. The touchstart function is called for each touch, so you can store all of them :var touches = [];stage.touchstart = mousedown();stage.touchend = mouseup();var mousedown = function(event){ var touch = { id: event.data.identifier, pos: event.data.getLocalPosition(this.view) }; touches.push(touch);};var mouseup = function(event){ for (var i = 0; i < touches.length; i++) { if(touches[i].id === event.data.identifier) { touches.splice(i,1); } };};This worked for me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.