multitouch

I am new to corona and specially this multitouch idea so i am very confused.

How multitouch works? say i have 1 button with tap event listener and another with touch event listener.

Now how do i know which one the player is touching? can somebody explain with an example code please?

Thanks

http://developer.coronalabs.com/content/events-and-listeners

http://docs.coronalabs.com/guide/events/detectEvents/index.html

Multitouch is not Corona specific but device specific (and os). Let’s take it like this:

if you use app with one finger then it’s “normal” mode. Let’s say you have 2 buttons on screen. With normal case you can touch only one. To touch other you must pull finger up (end touch event) and press 2nd button. With multitouch you can press this 2 buttons simultanousley.  Currently devices support up to 10 touches simultanously. So you can have 10 buttons on screen and touch each one with all your fingers in the same moment.

Keyboard example:

Normal mode is when you open text editor and press with your fingers many keys at once. What you will see will be only one letter on screen and to type next one you have to release key with character from screen. With multitouch all pressed characters will show.

Tech stuff:

What’s happening is device detecting where your skin is making disturbances in screen (for simplity - what is distirbuted is capacity of capacitors hidden under/in screen). It finds where this disturbance is the biggest and tells Corona x and y position on screen when this occured. When you enable multitouch, then not one disturance but multiple ones are detected.

if i have 3 buttons like in the example below…

How i setup multitouch? can someone show me please?

Thanks

local function jumpListener (self, event) end local function attackEvent(event) end local function kickEvent(event) end local buttonA = display.newCircle( 600, 400, 35 ) buttonA.name = "buttonA" buttonA:addEventListener ( "tap", jumpListener ) --ButtonB buttonB = display.newCircle( 700, 400, 35 ) buttonB.name = "buttonB" buttonB:addEventListener ( "tap", attackEvent ) --ButtonC local buttonC = display.newCircle( 700, 300, 35 ) buttonC.name = "buttonC" buttonC:addEventListener ( "tap", kickEvent )

You do not set up miltitouch, you just turn it on with 

system.activate("multitouch")

and it turns on Android/iOS feature which enables multitouch for your application.

As for your code you change nothing. If you do not activate multitouch then you can press button only one button and only one of jumpListener, attackListener or kickListener will be executed (because only 1 touch/tap was detected). When you activate multitouch and at once press all 3 buttons then all this function will be executed simultanousley (not literaly but one after another in program execution loop)

http://developer.coronalabs.com/content/events-and-listeners

http://docs.coronalabs.com/guide/events/detectEvents/index.html

Multitouch is not Corona specific but device specific (and os). Let’s take it like this:

if you use app with one finger then it’s “normal” mode. Let’s say you have 2 buttons on screen. With normal case you can touch only one. To touch other you must pull finger up (end touch event) and press 2nd button. With multitouch you can press this 2 buttons simultanousley.  Currently devices support up to 10 touches simultanously. So you can have 10 buttons on screen and touch each one with all your fingers in the same moment.

Keyboard example:

Normal mode is when you open text editor and press with your fingers many keys at once. What you will see will be only one letter on screen and to type next one you have to release key with character from screen. With multitouch all pressed characters will show.

Tech stuff:

What’s happening is device detecting where your skin is making disturbances in screen (for simplity - what is distirbuted is capacity of capacitors hidden under/in screen). It finds where this disturbance is the biggest and tells Corona x and y position on screen when this occured. When you enable multitouch, then not one disturance but multiple ones are detected.

if i have 3 buttons like in the example below…

How i setup multitouch? can someone show me please?

Thanks

local function jumpListener (self, event) end local function attackEvent(event) end local function kickEvent(event) end local buttonA = display.newCircle( 600, 400, 35 ) buttonA.name = "buttonA" buttonA:addEventListener ( "tap", jumpListener ) --ButtonB buttonB = display.newCircle( 700, 400, 35 ) buttonB.name = "buttonB" buttonB:addEventListener ( "tap", attackEvent ) --ButtonC local buttonC = display.newCircle( 700, 300, 35 ) buttonC.name = "buttonC" buttonC:addEventListener ( "tap", kickEvent )

You do not set up miltitouch, you just turn it on with 

system.activate("multitouch")

and it turns on Android/iOS feature which enables multitouch for your application.

As for your code you change nothing. If you do not activate multitouch then you can press button only one button and only one of jumpListener, attackListener or kickListener will be executed (because only 1 touch/tap was detected). When you activate multitouch and at once press all 3 buttons then all this function will be executed simultanousley (not literaly but one after another in program execution loop)

Hi guys…

I copy this file from Corona

i have this first inside my createScene

system.activate("multitouch")

then this

local bg = display.newRect( 0, 0, 320, 480 ) local output = native.newTextBox( 0, 20, 320, 240 ) output.size = 12   function showTouch(event)     -- Display the Event info on the screen     output.text = output.text .. "\nPhase: " .. event.phase     output.text = output.text .. "\n(" .. event.x .. "," .. event.y .. ")"     output.text = output.text .. "\nId: " .. tostring( event.id ) end   bg:addEventListener("touch", showTouch)   -- Deactivate multitouch after 5 seconds timer.performWithDelay( 8000, function() system.deactivate("multitouch") end )

and test it on my iPad and nothing happens I just see a white rectangle.

is there any sample Code app that I can run on my iPad to see how it works?

like coolromin said – it is very confusing for beginners like us

thanks

There is a sample project included in your ‘CoronaSDK’ file.
Find the file on your computer and choose the sample project:
CoronaSDK > SampleCode > PlatformSpecific > Multitouch-iPad

All multitouch requires is giving specified touch events a unique id, that way the each event won’t get treated as the same one.

I was a beginner too. :wink:

-Saer

Hi guys…

I copy this file from Corona

i have this first inside my createScene

system.activate("multitouch")

then this

local bg = display.newRect( 0, 0, 320, 480 ) local output = native.newTextBox( 0, 20, 320, 240 ) output.size = 12   function showTouch(event)     -- Display the Event info on the screen     output.text = output.text .. "\nPhase: " .. event.phase     output.text = output.text .. "\n(" .. event.x .. "," .. event.y .. ")"     output.text = output.text .. "\nId: " .. tostring( event.id ) end   bg:addEventListener("touch", showTouch)   -- Deactivate multitouch after 5 seconds timer.performWithDelay( 8000, function() system.deactivate("multitouch") end )

and test it on my iPad and nothing happens I just see a white rectangle.

is there any sample Code app that I can run on my iPad to see how it works?

like coolromin said – it is very confusing for beginners like us

thanks

There is a sample project included in your ‘CoronaSDK’ file.
Find the file on your computer and choose the sample project:
CoronaSDK > SampleCode > PlatformSpecific > Multitouch-iPad

All multitouch requires is giving specified touch events a unique id, that way the each event won’t get treated as the same one.

I was a beginner too. :wink:

-Saer