I'd like to use "CGRectIntersectsRect" for collision detect like following.
if (CGRectIntersectsRect(charRect, enemyRect)) {
NSLog(@"***COLLISION***");
}
When I define CCSprite, I define like following.
CCSprite* charSprite = [CCSprite spriteWithTexture:charSheet.texture rect:CGRectMake(0, 0, 64, 96)];
So, it includes "CGRectMake(0, 0, 64, 96)]"
I guess that CCSprite have information of "rect".
But, I couldn't fine how to get information of "rect" from CCSprite instance.
I tried methods I hope, but they doesn't exist
charSprite.rect
charSprite.getRect
charSprite.rect_
charSprite.contentRect
...
Writing them of below are troublesome.
charRect = CGRectMake(
charSprite.position.x - (charSprite.contentSize.width/2),
charSprite.position.y - (charSprite.contentSize.height/2),
charSprite.contentSize.width,
charSprite.contentSize.height
);
enemyRect = CGRectMake(
enemySprite.position.x - (enemySprite.contentSize.width/2),
enemySprite.position.y - (enemySprite.contentSize.height/2),
enemySprite.contentSize.width,
enemySprite.contentSize.height
);