Irn3rd Posted November 6, 2014 Share Posted November 6, 2014 var sprite = new game.Sprite('present.png', this.positionX, this.positionY, { }); sprite.interactive = true; sprite.mousedown = function(event) { console.log("Mousedown X:" + event.global.x + ", Y:"+event.global.y); // Android double tap fix if (game.device.mobile && !event.originalEvent.changedTouches) return; game.scene.addScore(); this.remove(); } game.scene.addTween( sprite.position, { y:game.system.height }, 2000, { easing:'Quadratic.In', onComplete: function(){ if(sprite.__hit === true) { sprite.remove(); }else{ game.scene.takeLife(); sprite.remove(); } } } ).start(); sprite.addTo(game.scene.stage);I'm adding a new sprite with the code sample above. it works on desktop fine, but when i move to mobile to test the touch/click event isn't captured at all. Any idea why this might be happening? Many thanks Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted November 6, 2014 Share Posted November 6, 2014 Hi @lrn3rd Try to write your function this way ... rock.click = rock.tap = function() { Hope this helps Quote Link to comment Share on other sites More sharing options...
enpu Posted November 6, 2014 Share Posted November 6, 2014 There are separate functions for mouse and touch. Mouse functions:mousedown, mouseup, mousemove, click Touch functions:touchstart, touchend, touchmove, tap 7Game 1 Quote Link to comment Share on other sites More sharing options...
Irn3rd Posted November 6, 2014 Author Share Posted November 6, 2014 Thank you both for your replies, I shall try everything mentioned. Seems like was just an oversight on my part. Gracias Quote Link to comment Share on other sites More sharing options...
7Game Posted February 24, 2015 Share Posted February 24, 2015 @enpu If it is possible than also put the Touch Event Example or cheat seat on declare event in PandaJs Doc.i m trying to touch a button in desktop it works f9 but in any mobile device its not working by default. Now i got the touch events so let me try and see what happend. Quote Link to comment Share on other sites More sharing options...
Neso Posted February 24, 2015 Share Posted February 24, 2015 There are two types of callback functions interactive layers offer. In order to support both touch and mouse click. You will need to provide callbacks to both tap and click. 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.