표준 iOS 그래픽 라이브러리 (Core Graphics)를 사용하여 이미 멀티 터치 이미지 회전을 구현했습니다.Cocos2d 멀티 터치 스프라이트 회전을 구현하는 방법은 무엇입니까?
그것은 다음과 같습니다
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] == 2) {
NSArray *twoTouches = [touches allObjects];
UITouch *first = [twoTouches objectAtIndex:0];
UITouch *second = [twoTouches objectAtIndex:1];
CGFloat currentAngle = angleBetweenLinesInRadians([first previousLocationInView:self.view], [second previousLocationInView:self.view], [first locationInView:self.view], [second locationInView:self.view]);
pic1.transform = CGAffineTransformRotate(pic1.transform, currentAngle);
}
}
은 지금은 내적인 Cocos2D 프로젝트에이 솔루션을 구현하기 위해 노력하고있어. 먼저 CCTouchDispacher를 init 메서드에 등록했습니다. 내 ccTouchMoved 기능에서
- (id) init
{
...
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
...
}
나는 (NSSet *)에 (UITouch *)를 변경하고 단지 모든 것이 정확했다 확인하기 위해 프로젝트를 만들었습니다. 결과적으로 다음과 같은 경고 메시지가 나타납니다. "호환되지 않는 Objective-C 유형이 'struct NSSet *'을 초기화하고 'struct UITouch *'가 필요합니다." "
모든 것이 올바르게 작동하는 것처럼 보였으므로 계속 이동하여 (NSSet *) touch에서 첫 번째 및 두 번째 터치 객체를 추출하려고했습니다.
- (void)ccTouchMoved:(NSSet *)touch withEvent:(UIEvent *)event {
if ([touch count] == 2) {
NSArray *twoTouches = [touch allObjects];
UITouch *first = [twoTouches objectAtIndex:0];
UITouch *second = [twoTouches objectAtIndex:1];
}
}
지금 내가 근무하는 컴파일하려고하지만 난 아이폰 시뮬레이터를 통해 ccTouchMoved를 트리거 한 후, 나는 오류 메시지가 다음 있어요 "- [UITouch 계산] : 인식 할 수없는 선택기 인스턴스 0x542d6a0 '에 보내".
누군가가이 Cocos2d ccTouchMoved 메서드를 사용하여 멀티 터치 이벤트를 인식하고 처리하는 방법을 설명해 주실 수 있습니까?
감사합니다.
안녕 팩맨, 당신은 당신이 angleBetweenLinesInRadians을 구현 어떻게했는지 말해 줄 수있다 다수의 접촉을 캡처 할로
? 감사. –