JeZxLee Posted August 15, 2017 Share Posted August 15, 2017 Hi, I want to add support for multi-touch on Android devices today. I just need to detect only two simultaneous taps (one on directional pad & one on button) Is there some example code I can look at to learn the above? Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 15, 2017 Share Posted August 15, 2017 There are no examples, make one yourself, I'll add it to pixi-examples later The idea is that you manage different InteractionData's (event.data). Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 15, 2017 Author Share Posted August 15, 2017 Does PixiJSv4 support muti-touch? Little lost... JeZxLee Quote Link to comment Share on other sites More sharing options...
themoonrat Posted August 15, 2017 Share Posted August 15, 2017 It just works. If you had a pointerdown callback on your directional pad, and a pointerdown callback on your buttons, then they'll both get called even if you have the screen held down elsewhere. If you have just a pointerdown on the top level of interactionManager, then look within the event.data object and you'll see all of the data that exists for that event, including information to distinguish between different presses Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 15, 2017 Author Share Posted August 15, 2017 I'll play around with it later today... Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 15, 2017 Author Share Posted August 15, 2017 Hi, Do I need to use two "pointerdown" functions to register two fingers on Android screen? renderer.plugins.interaction.on('pointerdown', function(event) { MouseCoordinates = event.data.global; TouchScreen = true; }); renderer.plugins.interaction.on('pointerup', function(event) { MouseCoordinates = event.data.global; TouchScreen = false; }); Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 15, 2017 Share Posted August 15, 2017 For different fingers, "event.data" is different. Look at it closely. Unfortunately, I didnt work with this feature, @themoonrat can help you but only if you investigate what is stored in event.data first! Don't ask him if you havent tried to extract info from "event.data", he's very busy Quote Link to comment Share on other sites More sharing options...
Taz Posted August 15, 2017 Share Posted August 15, 2017 Probably you'll have an easier time if you use separate event handlers for pad and button. Like this for example: pad.interactive = true; pad.on('pointerdown', function (event) { // do stuff when press down on direction pad }); pad.on('pointerup', function (event) { // do stuff when press is released on direction pad }); button.interactive = true; button.on('pointerdown', function () { // do stuff when button is clicked }); EDIT: Also the examples for Click and Interactivity are good reference for this - that's where I learned above technique.. Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 15, 2017 Author Share Posted August 15, 2017 After 5 hours I almost got it... Can someone look at my code and help out? Code is downloadable on the title screen at below URL link in signature... JeZxLee Quote Link to comment Share on other sites More sharing options...
Taz Posted August 15, 2017 Share Posted August 15, 2017 It seems like you have 6 buttons (4 arrow buttons and 2 round buttons). So I think it's easiest and most straightforward to approach it like the interactivity example and give each of the 6 buttons its own event handlers. And if you need to know when multiple buttons are being pressed at once (instead of handling each button separately) then you can set a flag for each button for instance to track whether it's being pressed down or not. EDIT: Note: The example is different since each button is handled by same functions but you can adapt it to use different function for each button like I showed above. Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 15, 2017 Author Share Posted August 15, 2017 My goal is to support touch and drag on the directional pad (4 buttons) while supporting simultaneous touch of either action button(2 buttons). Little tired, need to rest - I'll try this again tonight... JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 17, 2017 Author Share Posted August 17, 2017 Hi, Been looking at the docs. Is this where I should be looking?:http://pixijs.download/release/docs/PIXI.interaction.InteractionManager.html Still don't have this working...any help would be appreciated... Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted August 23, 2017 Author Share Posted August 23, 2017 Got it working, thanks! (URL above has been updated) JeZxLee 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.