Working on game where plates will be falling from top to bottom. Some plates will also “bounce” on the ground and then start moving upwards again. This leads situations where a falling plate collides with a “rising plate”.
My problem? I don´t know how to detect this collision.
Since all the plates comes from the same class I can´t write
if(CGRectIntersectsRect([self boundingBox], [self boudingBox]))
since this statement will always be true.
I create the plates with a for-loop:
for(i=0; i<9; i++){
Plate *plate = [Plate initPlate];
}
and then just reuse these plates throughout the game.
Any ideas or work arounds on how I detect a collision between two plates? Any advice would be greatly appreciated.
Regards.
You need to have a class that manages (for example using a NSMutableArray) the set of plates, and instead of checking for collisions on the Plate class you do it on this new class.
Assuming your array is:
You can do this:
Or, more elegantly: