Collisions and Groups in Game Lab (for Tile Map)

Hi there. I’m wondering if anyone has had success implementing a Tile Map in Game Lab. I’d like to, but I’ve come across what seems like a major shortcoming: There does not seem to be a way to modify the collision behavior of specific sprites (indexes) in a group. I understand that you can use the setColliderEach method on the whole group, but that won’t fit the bill for a Tile Map where I want to set different collider options for different sprites in the ‘tiles’ group (e.g.: some are walls, some are bouncy, some are just air).

I’m trying to use a for-loop to traverse the group and assign collision behaviors, but if I use a line like this: tiles[i].collide(player); - It produces an error: “Error: overlap can only be checked between sprites or groups”.

It seems like this is a bug, since a particular index of a group really is a sprite, right? Any ideas?

In your drawMap function, filter each sprite that the player should not go in into a group. In the function draw use collide() to collide the player with that group. This should work, if it doesn’t contact me!

1 Like

That did it! Good to know that a sprite can be in multiple groups at once! Not sure why they don’t allow access to collision behavior through group traversal, but this work around should do the trick, thank you!!