나는 당신이 그것을 통해 그것을 할 수 있었다는 것을 알고 있습니다 :
<CCLayerObject>.isTouchEnabled = YES;
... 터치 디스패처 등록과 함께 :
-(void)registerWithTouchDispatcher
{
[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
... 그리고 콜백을받습니다 :
-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint point = [self convertTouchToNodeSpace:touch];
NSLog(@"X:%ftY:%f", point.x, point.y);
}
하지만 V3에서는 무엇을해야합니까?
내가해야 할 일은 다음과 같습니다.
CCScene 생성자에서 터치를 활성화합니다.
[self setUserInteractionEnabled:YES];
다음 위치에 touchBegan 메서드를 추가합니다.
- (void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
NSLog(@"touchBegan");
}
따다! V2보다 V3에서 훨씬 쉽습니다!
선택적으로 다음을 수행 할 수도 있습니다.
[self setMultipleTouchEnabled:YES];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다