identifying collision objects

I have multiple objects that can collide with each other and with an array of static objects. I need to identify which object hit another. This is to determine action/inaction and score/no score situations.

In the attachment I have a code snippet showing the setup of a set of blocking objects for the game. Random collision events with these objects will happen through out the game. I need to determine what  object hit which blocker to determine what action and/or point assignment needs to be made.

The file contains the data in the table used to define the blocker objects these table from left to right are:

X, Y, Rotation, png name, object name, object class (reactive on non-reactive), event type (based on class), and points (if any).

Finally to the point how can I determine what blocker was hit and by what object? I expected to be able to loop through the boardGroup to pull out the sub-table containing a specific set of blocker information based on the blocker.myName value but have not been successful.

Check the last post on this topic as i explained exactly what you want. (I think)

Side Note – Your sample isn’t a sample as it doesn’t work… Kinda hard to understand what you want… –

https://forums.coronalabs.com/topic/60143-collision-if-statement/#entry311684

Well check the post out and reply by if that’s what you wanted!

Good Luck!

SonicX278,

yes indeed it does not work when you leave out essential pieces. :rolleyes:

Here is what I had hoped to convey originally:

  1. I want to load these blocker objects into a group giving each a unique name and some attributes. As is shown in the for k, v in pairs(levelB[delta]) do loop.

  2. Once a collision has occurred I want to loop through the definitions now stored in the group to determine which blocker was involved. e.g. you sample code (much appreciated by the way).

I ran your example and understand how it works, so it looks like all I need to do is place a loop around the IF…THEN to capture the correct object by the ‘myName’ attribute. Now if this is true I go to my next question: How do I loop through the group table to get at the data I need?

I am not well versed in several aspects of properly utilizing tables to the best advantage in Lua.

Check the last post on this topic as i explained exactly what you want. (I think)

Side Note – Your sample isn’t a sample as it doesn’t work… Kinda hard to understand what you want… –

https://forums.coronalabs.com/topic/60143-collision-if-statement/#entry311684

Well check the post out and reply by if that’s what you wanted!

Good Luck!

SonicX278,

yes indeed it does not work when you leave out essential pieces. :rolleyes:

Here is what I had hoped to convey originally:

  1. I want to load these blocker objects into a group giving each a unique name and some attributes. As is shown in the for k, v in pairs(levelB[delta]) do loop.

  2. Once a collision has occurred I want to loop through the definitions now stored in the group to determine which blocker was involved. e.g. you sample code (much appreciated by the way).

I ran your example and understand how it works, so it looks like all I need to do is place a loop around the IF…THEN to capture the correct object by the ‘myName’ attribute. Now if this is true I go to my next question: How do I loop through the group table to get at the data I need?

I am not well versed in several aspects of properly utilizing tables to the best advantage in Lua.