您好stackoverflow社区!
如何在cocos2d中检测与父级精灵的子级精灵碰撞?
目前我的代码是这样的:
CGSize screenSize = [[CCDirector sharedDirector]winSize];
parentJumper = [CCSprite spriteWithFile:@"inviBtn.png"];
jumper = [CCSprite spriteWithFile:@"jumperRight.png"];
plat = [[Platform alloc]init];
plat = [Platform spriteWithFile:@"platformBlack.png"];
plat.position = ccp(160,100);
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0/60)];
jumper.anchorPoint = ccp(0.5, 0);
jumper.position = ccp(0, 20);
parentJumper.position = ccp(screenSize.width/2, 0);
[self addChild:plat];
[self addChild:parentJumper];
[parentJumper addChild:jumper];
现在我如何检测“跳线”& “的高原”
感谢您的帮助!
答案 0 :(得分:-1)
通常你可以像这样检查碰撞:
if(CGRectIntersectsRect([jumper boundingBox], [plat boundingBox])) {
//Handle collision<br>
}