segunda-feira, 29 de outubro de 2012

Using multi touch in CoronaSDK

Multi-touch is a very useful feature for games and mobile apps and comes frees of charge in native applications, but how do you use it in CoronaSDK?

Its simpler than one can imagine.

On your main.lua add the following activation codeline


With this your "touch" listener will have more than one touch in its event variable, an id property is available to identify each different touch.

Ok but it would not be me posting if I let you guys with only that ummm lets say dumb tip.

To try it out create a blank project with a new main.lua and our multitouch activation.

Let us place two round buttons to control a ball that will move it horizontally and vertically when these buttons are pressed. Also add a name variable with a differente identifier for each button, we will use it to know when each one has been touched.


You're probably seeing something similar to this

Now to the moving part.

Create a function for listening the touch actions and add it to both buttons.



When you execute it in the CoronaSDK Simulator one thing will come to mind: "How the hell I test it if I can only use single touches?"

Yes my friend that is an annoying problem, you will have to build your application and test it directly into your device. If you don't have one I suggest you to check if corona ultimote or luaglider (cider) have anything useful on this case.

Happy touching.

Nenhum comentário: