icp Posted February 17, 2015 Share Posted February 17, 2015 Is it possible to bind touchmove to mousemove ? If so , how?I got a working function body for mousemove/desktop but it does not work on touchmove/mobiles. Quote Link to comment Share on other sites More sharing options...
SkyzohKey Posted February 17, 2015 Share Posted February 17, 2015 You can do something like that :game.createScene('SceneName', { init: function() { this.container = new game.Container.addTo(game.system.scene); this.container.mousemove = this.container.touchmove = this.mousemove.bind(this); }, mousemove: function (e) { console.log(e); }}); Quote Link to comment Share on other sites More sharing options...
icp Posted February 17, 2015 Author Share Posted February 17, 2015 Thank you , but it still does not work. I need to use it with :game.createClass('Player','Graphics', Quote Link to comment Share on other sites More sharing options...
ericjbasti Posted February 18, 2015 Share Posted February 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
SkyzohKey Posted February 18, 2015 Share Posted February 18, 2015 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 + ')'); }}); Quote Link to comment Share on other sites More sharing options...
icp Posted February 18, 2015 Author Share Posted February 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
Neso Posted February 19, 2015 Share Posted February 19, 2015 You will need to add hitArea and interactive in order to listen to events. Try adding the code below to your init function.this.interactive = true;this.hitArea = new game.HitRectangle(x, y, width, height); //width and height of touchable area and x and y positions Quote Link to comment Share on other sites More sharing options...
icp Posted February 24, 2015 Author Share Posted February 24, 2015 I'm still not able to get any touchmove output on mobile devices. I'm not talking about touchdown or other events but especially about touchmove.Thanks everyone for the efforts .Meanwhile I will try to find a solution. Quote Link to comment Share on other sites More sharing options...
7Game Posted February 25, 2015 Share Posted February 25, 2015 I find it on my animated Button Now it works on all devices. Quote Link to comment Share on other sites More sharing options...
icp Posted February 25, 2015 Author Share Posted February 25, 2015 Nice, can you PM me the example? Quote Link to comment Share on other sites More sharing options...
7Game Posted February 26, 2015 Share Posted February 26, 2015 /*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 } 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.