저는 COSOS2d를 사용하여 iOS에서 게임을 만들고 있습니다. CCTouch 경계 상자가 생성되지 않음
이
은- (void)selectSpriteForTouch:(CGPoint)touchLocation {
CubeSprite * newSprite = nil;
for (CubeSprite *sprite in movableSprites) {
NSLog(@"tested against sprite %i", sprite.boundingBox.origin.x);
if (CGRectContainsPoint(sprite.boundingBox, touchLocation)) {
singleCube = true;
newSprite = sprite;
activeTag = sprite.tag;
break;
}
}
if (newSprite != selSprite) {
selSprite = newSprite;
}
}
그러나 어떤 이유로
가의 sprite.boundingBox가 올바르게 설정되지 않는, 큐브가 접촉되어 있는지 확인하기 위해 사용하는 방법 임이다."테스트 된 스프라이트"로그는 "스프라이트 0에 대한 테스트"를 인쇄합니다. 이는 화면에 스프라이트를 볼 수있는 것처럼 보이지 않습니다.
여기 내 현장에 큐브를 추가하는 데 사용하는 방법,
-(void)addCube:(CubeSprite *)cube {
int totalCubes = [cubes count];
[cube setPosition:ccp(700 - (totalCubes * 50), 120)];
[cubes addObject:cube];
[movableSprites addObject:cube];
[self addChild:cube];
}
것은 무엇 가능성이 잘못 될 수있어?
미리 감사드립니다.
편집, 여기 내 큐브 초기화 방법이
for (CubeSprite *sprite in movableSprites) {
CGRect projectileRect = [sprite boundingBox];
if (CGRectContainsPoint(projectileRect, touchLocation)) {
singleCube = true;
newSprite = sprite;
activeTag = sprite.tag;
break;
}
}