Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

touchmove


icp
 Share

Recommended Posts

the event object passed to a mouse event and a touch event are slightly different. Since you can have multiple touch events at once they are passed to you in an Array like 'targetTouches' or 'changedTouches'. What you can do if you don't care about multi-touch is simply have the mousemove and touchmove events call another function and pass in either e  or e.targetTouches[0]  to the function and it can have your standard code for both the mouse and touch. At that point e will have the appropriate clientX and clientY for you to work with. 

Link to comment
Share on other sites

 

Thank you , but it still does not work. I need to use it with :

game.createClass('Player','Graphics',

 

So you need to bind the mousemove/touchmove event of the class :

game.createClass('Player', 'Graphics', {  init: function()  {    this.mousemove = this.touchmove = this.mousemove.bind(this);  },  mousemove: function(event)  {    console.log('Mouse position (x: ' + event.global.x + ' - y: ' + event.global.y + ')');  }});
Link to comment
Share on other sites

I'm using Intel XDK , i think that might be the problem because I tried everything and still I can't get any response on touchmove via Crosswalk.

touchmove : function (e) {                var x = e.global.x;                var y = e.global.y;alert(x+y);            }

Even this code does not get any response.

Link to comment
Share on other sites

/*Here is the Example of Mouse Click & Mobile Tap Event. Must Impliment Both Event

 

 if(click!==undefined){

                if(sender===undefined){

                    sender=this;

                }

                this.click=click.bind(sender); //Here Desktop Mouse Event

                this.tap=click.bind(sender); //Here is Mobile Touch Event

 

            }
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...