touch screen collision

I’m wondering what code would I need for a touch screen collision on selected targets. Say a bank robber is holding a hostage, I’d like to have touch screen collision when I touch the robber and have him vanish after collision, and if I miss by touching hostage then hostage vanishes.

Hi @tj.reis,

For this, you don’t necessarily have to use physics. You can just use basic touch events, as introduced here:

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

That being said, if you need really detailed point detection, i.e. that you touch the robber’s head vs. the hostage’s shoulder, then you might need to use physics-based detection. In that case, I would just place a small circular sensor object at the touch point and sense which of the physical bodies it collides with.

Hope this helps,

Brent

Well I decided to go easy on this since it is my first try at making an app. I’ve read over the link and its very helpful, but I still can’t seem to find examples of where to put my robber.PNG in the code.

What I would like to do is have the robber spawn behind a bush(or a set location) for a set amount of time for the user to react, user will touch the robber. If robber is touched in the set amount of time then id like for robber to delete and be replaced with an eplosion.png graphic. The explosion graphic wont be animated since id like to acomplish this app by understanding the basics first. The explosion will last for a set amount of time before it deletes also.

There are a lot of different functions and I’m not sure which to use to make the robber appear and delete when touched, if touched before it slides back behind the bush.

Hi @tj.reis,

For this, you don’t necessarily have to use physics. You can just use basic touch events, as introduced here:

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

That being said, if you need really detailed point detection, i.e. that you touch the robber’s head vs. the hostage’s shoulder, then you might need to use physics-based detection. In that case, I would just place a small circular sensor object at the touch point and sense which of the physical bodies it collides with.

Hope this helps,

Brent

Well I decided to go easy on this since it is my first try at making an app. I’ve read over the link and its very helpful, but I still can’t seem to find examples of where to put my robber.PNG in the code.

What I would like to do is have the robber spawn behind a bush(or a set location) for a set amount of time for the user to react, user will touch the robber. If robber is touched in the set amount of time then id like for robber to delete and be replaced with an eplosion.png graphic. The explosion graphic wont be animated since id like to acomplish this app by understanding the basics first. The explosion will last for a set amount of time before it deletes also.

There are a lot of different functions and I’m not sure which to use to make the robber appear and delete when touched, if touched before it slides back behind the bush.