JeZxLee Posted August 3, 2017 Share Posted August 3, 2017 Hi, We finished our 1st PixiJSv4/Audio5js video game (look in my signature). We are starting a new game project on Monday using our new engine. Can someone tell us how to get touch [x,y] on Android devices? We tried to do this already, but never figured it out. Any help would be appreciated, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 3, 2017 Author Share Posted August 3, 2017 Hi, We need screen coordinates when finger touches *any* part of the Android screen, not a sprite... JeZxLee Quote Link to comment Share on other sites More sharing options...
Taz Posted August 3, 2017 Share Posted August 3, 2017 have you tried this for coordinates on the canvas? console.log("(" + event.data.global.x + ", " + event.data.global.y + ")"); If you want window coordinates not canvas coordinates you can also look into handling the touch events yourself. Quote Link to comment Share on other sites More sharing options...
themoonrat Posted August 3, 2017 Share Posted August 3, 2017 Events on renderer.plugins.interaction cover the whole screen renderer.plugins.interaction.on( 'pointerdown', () => { console.log('pointerdown') } ); Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 3, 2017 Author Share Posted August 3, 2017 8 minutes ago, themoonrat said: Events on renderer.plugins.interaction cover the whole screen renderer.plugins.interaction.on( 'pointerdown', () => { console.log('pointerdown') } ); How would I get [x,y] coordinates from above? Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
themoonrat Posted August 3, 2017 Share Posted August 3, 2017 Look at the data that's supplied in that event, just like the event data of any interaction callback. It's of type http://pixijs.download/dev/docs/PIXI.interaction.InteractionData.html Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 3, 2017 Author Share Posted August 3, 2017 Got it! Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 7, 2017 Author Share Posted August 7, 2017 Sorry, I can't seem to figure this out? I have: PIXI.Point MouseCoordinates; renderer.plugins.interaction.on( 'pointerdown', () => { MouseCoordinates = renderer.plugins.interaction.global } ); But it does not work? Any help would be appreciated, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
Taz Posted August 7, 2017 Share Posted August 7, 2017 You can get the coordinates like this: var MouseCoordinates; app.renderer.plugins.interaction.on('pointerdown', function(event) { MouseCoordinates = event.data.global; console.log(MouseCoordinates); }); Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 7, 2017 Author Share Posted August 7, 2017 Says: "undefined" in console? Quote Link to comment Share on other sites More sharing options...
Taz Posted August 7, 2017 Share Posted August 7, 2017 Hmm, it works for me on both macbook and on iPhone.. If you copy and paste the above into a stock pixi project it doesn't work? Are you on latest Pixi version 4.5.4? Or maybe try to copy and paste it into the basic pixi example?I don't why it wort work for you thou, sorry.. 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.