Hi,
I've got this strange collision problem.
I rotate my 'ant objects' with this piece of code, where 'absoluteDraaiHoek' is the direction in degrees:
Code:
#define DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) / 180.0 * M_PI)
CGAffineTransform cgCTM = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(absoluteDraaiHoek));
image.transform = cgCTM;
Then in the gameloop I check for collision like this:
Code:
if(CGRectIntersectsRect(tmpAnt.image.frame, player.image.frame)){
tmpAnt.collisionWithPlayer = YES;
}else{
tmpAnt.collisionWithPlayer = NO;
}
When collisionWithPlayer is true, the ant won't move.
But this results in the following situation:
As you can see the ant in the upperleft corner does not intersect with the players rect, but CGRectIntersectsRect returns true!
I suspect something is happening like the following screenshot:
Now my question is, when rotating an UIImageView, does the original frame rotate too? Or does its frame change like the second screenshot?
If so, how to handle that correctly?
Thanks in advance.