Jump to content

Need Android Muti-Touch Example...


JeZxLee
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...