0

私はこれを完全には理解していません。デフォルトのテンプレートを使用してタッチ処理を設定しようとしています。私が行った唯一の違いは、プロトコルを実装するクラスにタッチを処理する方法を委任したことです。問題は、kTouchPhase機能するのはkTouchPhaseCancelled.

-(void) update:(ccTime)delta
{
    if ([input isAnyTouchOnNode:self touchPhase:KKTouchPhaseAny])
    {

        CCLOG(@"Touch: beg=%d mov=%d sta=%d end=%d can=%d",
              [input isAnyTouchOnNode:self touchPhase:KKTouchPhaseBegan],
              [input isAnyTouchOnNode:self touchPhase:KKTouchPhaseMoved],
              [input isAnyTouchOnNode:self touchPhase:KKTouchPhaseStationary],
              [input isAnyTouchOnNode:self touchPhase:KKTouchPhaseEnded],
              [input isAnyTouchOnNode:self touchPhase:KKTouchPhaseCancelled]); 
    }

    CCDirector* director = [CCDirector sharedDirector];

    if (director.currentPlatformIsIOS)
    {
        [self gestureRecognition]; // Calls method pasted bellow

        if ([KKInput sharedInput].anyTouchEndedThisFrame)
        {
            CCLOG(@"anyTouchEndedThisFrame");
        }
    }

.->

-(void) gestureRecognition
{
    NSAssert(self.delegate != nil, @"Delegate must be non-nil");

    if (input.gestureTapRecognizedThisFrame)
    {
        [self.delegate moveObjectToNewPosition:input];
    }

そして、プロトコルを実装するデリゲートは、何をすべきかを決定しますmoveObjectToNewPosition:

-(void) moveObjectToNewPosition:(KKInput *)input
{
    //KKInput *input = [KKInput sharedInput];
    CGSize screenSize = [[CCDirector sharedDirector] winSize];

    CGPoint touchLocation = [input locationOfAnyTouchInPhase:KKTouchPhaseBegan];
    [self touchesBegan:touchLocation];

}


- (void)touchesBegan: (CGPoint)touchLocation
{
    CCLOG(@"x: %f y: %f", touchLocation.x, touchLocation.y);
}

しかし、私に座標を与える唯一のタッチフェーズは、KKTouchPhaseCancelledまたはKKTouchPhaseAny... ここで何が起こっているのですか?

4

1 に答える 1