dinther Posted May 19, 2015 Share Posted May 19, 2015 I want to make sure I get this control technically perfect before I translate the others. I would really appreciate a code review and feedback so I can get the rest right. Checkout the latest version of my dial knob. http://www.planetinaction.com/instrumentdemos/dialknob.htm The page shows two dial knobs. Each can be operated separately but they can not be operated simultaneously using multi-touch. I looked at the multi-touch example code and I believe I implemented it correctly but obviously it isn't working. Individual files: http://www.planetinaction.com/instrumentdemo Quote Link to comment Share on other sites More sharing options...
clement_cvL Posted May 19, 2015 Share Posted May 19, 2015 I posted this answer last day but never had some feedback : http://www.html5gamedevs.com/topic/14043-multi-touch-how-to-get-local-position-for-each-fingers/var touches = [];var fingerOnScreen = false;stage.touchstart = mousedown();stage.touchend = mouseup();var mousedown = function(event){ fingerOnScreen = true; var touch = { id: event.data.identifier || 0, // || 0 is to support desktop version pos: event.data.getLocalPosition(this.view) }; touches.push(touch);};var mousemove = function(event){for (var i = 0; i < touches.length; i++) {if(touches.id === (event.data.identifier || 0) ){touches.pos = event.data.getLocalPosition(this.view);}};}var mouseup = function(event) { for (var i = 0; i < touches.length; i++) { if(touches.id === (event.data.identifier || 0)) { touches.splice(i,1); } }; if(touches.length === 0) // no more fingers on screen{fingerOnScreen = false;}}; It works, and then you can manage each button with the correspondant 'touch' Quote Link to comment Share on other sites More sharing options...
marksyzm Posted October 13, 2017 Share Posted October 13, 2017 I can confirm that this method works well. The identifier changes to `MOUSE` when using mouse events so be careful with your integers. 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.