I have a game using Farseer engine to handle collision. I have three entities:
- a ball
- a player
- a goal
They all have their own body, which is added to the world and they collide correctly. The OnCollision response function is declared as:
bool CrystalOnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact);
When they collide, I can access the fixture ID, or the body with the ID, but I want to access the actual object that it collides with in a good way.
For example, when the player collides with the ball, it should pick up the ball. When this happen, the player should be signaled that it has a ball, and the ball should be signaled that it has an owner.
How can this be done? I'm thinking about a static list for all the objects, but that breaks all my previous design and seems slow. Also it tingles my bad design bell in the back of my head. Im also thinking about implementing a secondary collision system for events like that, but it seems really stupid when I have a collision engine.
Aucun commentaire:
Enregistrer un commentaire