Can a physics object collide with all objects in a group using local collisions?

Hey.

I have anout 40 objects which are all static and interact with a dynamic player character.

The static objects are all added to the same group.

I need a boolean to set to true whenever the player is in contact with,(event.phase=began will suffice) any of the objects in the group.

Is there a simple, (lazy) way to get the player character to listen for collisions with any object inside a group, or will I have to manually code 40 or so individual local collisions?

Thanks

Dan

Don't mix physics and groups it won't work.

Basically you set a .myName tag to every object then add a collision event listener to your player, you can check what objects it collides with using the .myName tag.

Hi Notts.

I'm aware it's generally bad practice, but I really don't want to have a collision function 40 x as long as this:

1
2
3
4
5
6
7
8
9
function onLocalCollision( self, event )
        if ( event.phase == "began" ) then
                                ----------------------------------player hits ground---------------------------------------------------------------------------
                        if (self.myName == "player1" and event.other.myName == "object1") then
                                                                myBool = true
                                                                print(canpush)
                        end
                end
        end

All 40 objects, do something like this;

obj.status = "canCollide"

Then your collision function could just have;

if event.other.status = "canCollide" then

Does that do what you're after?

Peach :)

views:1555 update:2011/10/11 8:57:46
corona forums © 2003-2011