kdrnic/box2dweb

enhance "demo" example to handle touch events

Opened this issue · 4 comments

What steps will reproduce the problem?
1. Export the demo projects to IOS/Android using Marmalade/Phonegap
2. Run demo on Device and use finger to grab and throw objects
3. Objects will not respond to touch events

What is the expected output? What do you see instead?
Would be great if one could grab and throw B2D objects

What version of the product are you using? On what operating system?


Please provide any additional information below.
The following additional handlers will allow you to run the example on IOS and 
android devices

document.addEventListener('touchstart', function(event) {
            isMouseDown = true;
            var touch = event.touches[0];
            mouseX = (touch.pageX - canvasPosition.x) / 30;
            mouseY = (touch.pageY - canvasPosition.y) / 30;
            //alert("Touch x:" + touch.pageX + ", y:" + touch.pageY + ',len='+event.touches.length);
        }, false);

        document.addEventListener('touchend', function(event) {
            isMouseDown = false;
            mouseX = undefined;
            mouseY = undefined;
            //alert('Tend' + event.touches.length);         
        }, false);


        document.addEventListener('touchmove', function(event) {
            event.preventDefault();
            var touch = event.touches[0];
            mouseX = (touch.pageX - canvasPosition.x) / 30;
            mouseY = (touch.pageY - canvasPosition.y) / 30;
            //alert("MOve - Touch x:" + touch.pageX + ", y:" + touch.pageY);
        }, false);



Original issue reported on code.google.com by nan...@gmail.com on 5 Aug 2012 at 7:03

[deleted comment]
[deleted comment]
[deleted comment]
codingowl.com/readblog.php?blogid=137

Original comment by shekhars...@gmail.com on 10 Nov 2012 at 1:25