Jump to content

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 post
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 post
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 post
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 post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...