I’ve been trying to get my game to use multitouch, I want to get it so when you’re holding down on one object, you can tap on another and stuff will happen. However, I can’t do both at the same time when I test on my device. I haven’t been able to find a clear tutorial for this online and I’m really confused.
multitouch is a bit confusing at first. once I get home I’ll post some code unless someone beats me to it. also have you looked at the code exchange new and old.
Thanks. I appreciate it. I still haven’t figured it out at all…
save this as main.lua and run
on device it will show all touches. on sim it will only show one touch but you can change the
simTouch variable in code to simulate extra touches.
system.activate( 'multitouch' ) local txt = display.newText( 'Touch not detected.', 0, 0, nil, 32 ) txt.y = display.contentCenterY txt.x = display.contentCenterX local text = '' -- number of touches to show in simulator local simTouch = 1 local function touch(e) local phase = e.phase local id = e.id if phase == 'began' or phase == 'moved' then text = '' local touches, count = {}, 0 touches[e.id] = e or {} -- if on simulator simulate extra touches, offset x/y values if system.getInfo( 'environment' ) == 'simulator' then for a = 2, simTouch do touches['sim'..a] = { x = e.x+(a\*10), y = e.y+(a\*10) } end end for k, v in pairs(touches) do count = count + 1 text = text..count..':['..v.x..','..v.y..'] ' end end if phase == 'ended' then text = 'Touch not detected.' end txt.text = text end Runtime:addEventListener( 'touch', touch )
OK, so apparently my phone and my sister’s Kindle just aren’t detecting the second touch, I think. Is this because my phone (Kyocera Hydro) and my sister’s Kindle Fire HD don’t have multitouch?
But if it does work, do I have to pass specific parameters to get it to work or can I just activate multitouch and it’ll work?
I’m pretty sure the Kindle Fire (at least 1st generation) doesn’t support multi-touch. I don’t know about your phone. There is a multi-touch sample app in the CoronaSDK/SampleCode that you can use to test and see if it’s supported.
Rob
OK, apparently my phone DOES support multi-touch, what do I have to do to get it to register the multiple touches in my app? Do I have to set the target and stuff? How do I do that?
Try the Multi-touch sample app.
OK, I think I’m understanding it a little bit. Do I have to do something different to make the touches (depending on the certain objects touched) to do separate things?
EDIT: actually, I still don’t get it at all. I’m reading the sample app and for some reason it’s just not registering. Do I HAVE to pass the isFocus to have multitouch work?
EDIT2: I fixed it, I only have a faint idea how, but it works now. Thanks Rob and jstrahan! It really helped.
multitouch is a bit confusing at first. once I get home I’ll post some code unless someone beats me to it. also have you looked at the code exchange new and old.
Thanks. I appreciate it. I still haven’t figured it out at all…
save this as main.lua and run
on device it will show all touches. on sim it will only show one touch but you can change the
simTouch variable in code to simulate extra touches.
system.activate( 'multitouch' ) local txt = display.newText( 'Touch not detected.', 0, 0, nil, 32 ) txt.y = display.contentCenterY txt.x = display.contentCenterX local text = '' -- number of touches to show in simulator local simTouch = 1 local function touch(e) local phase = e.phase local id = e.id if phase == 'began' or phase == 'moved' then text = '' local touches, count = {}, 0 touches[e.id] = e or {} -- if on simulator simulate extra touches, offset x/y values if system.getInfo( 'environment' ) == 'simulator' then for a = 2, simTouch do touches['sim'..a] = { x = e.x+(a\*10), y = e.y+(a\*10) } end end for k, v in pairs(touches) do count = count + 1 text = text..count..':['..v.x..','..v.y..'] ' end end if phase == 'ended' then text = 'Touch not detected.' end txt.text = text end Runtime:addEventListener( 'touch', touch )
OK, so apparently my phone and my sister’s Kindle just aren’t detecting the second touch, I think. Is this because my phone (Kyocera Hydro) and my sister’s Kindle Fire HD don’t have multitouch?
But if it does work, do I have to pass specific parameters to get it to work or can I just activate multitouch and it’ll work?
I’m pretty sure the Kindle Fire (at least 1st generation) doesn’t support multi-touch. I don’t know about your phone. There is a multi-touch sample app in the CoronaSDK/SampleCode that you can use to test and see if it’s supported.
Rob
OK, apparently my phone DOES support multi-touch, what do I have to do to get it to register the multiple touches in my app? Do I have to set the target and stuff? How do I do that?
Try the Multi-touch sample app.
OK, I think I’m understanding it a little bit. Do I have to do something different to make the touches (depending on the certain objects touched) to do separate things?
EDIT: actually, I still don’t get it at all. I’m reading the sample app and for some reason it’s just not registering. Do I HAVE to pass the isFocus to have multitouch work?
EDIT2: I fixed it, I only have a faint idea how, but it works now. Thanks Rob and jstrahan! It really helped.