읽어 주셔서 감사합니다. 어떤 이유 Cocos2D TouchesEnded를 사용하면 스프라이트에 액세스 할 수 없습니까?
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint location = [[CCDirector sharedDirector] convertToGL: [touch locationInView:touch.view]];
CGRect myRect = CGRectMake(100, 120, 75, 113);
int tjx = sprite.position.x;
if(CGRectContainsPoint(myRect, location)) {
tjx ++;
}
}
,
ccTouchesEnded
는 내 "스프라이트"에 접근을 허용하지 않습니다. 또한
CGRectMake
과 같이 사용하려고 :
CGRectMake(sprite.position.x, sprite.position.y, sprite.contentSize.Width, sprite.contentSize.Height)
하지만 내 스프라이트의 위치 또는 높이를 액세스 할 수 없습니다. 나는 init 메소드에서 선언 될 때 "스프라이트"를 선언하지 않고 자식에게 추가한다.
도와주세요 !! 나는 여기서 정말로 간단한 것을 놓치고 있다고 확신한다.
Ktag 메서드를 사용하여이 문제가 해결되었습니다. Rob 정말 고마워! – maiko