1

kobold2d の KKInput を使用して、パン ジェスチャ認識エンジンを使用してドラッグ アンド ドロップを行います。iPhone がテーブルの上に平らに置かれている場合は完全に機能しますが、電話を自分の方に傾けると、翻訳が完全に間違っているように見え、正常に動作しなくなります。実際、iPhone が逆さまになっていると思われるようです。

私は何か間違ったことをしていますか?

サンプルコード:

if([input gesturePanBegan])
    {
        for( CCSprite* item in self.View.children )
        {
            bool result = [input isAnyTouchOnNode:item touchPhase: KKTouchPhaseAny];
            if (result)
            {
                itemPanning = item;
                originalPostion = item.position;

            }
        }
        CCLOG(@"%f y translation %f x translation", input.gesturePanTranslation.y , input.gesturePanTranslation.x);
        if(itemPanning != NULL)
        {
            [itemPanning setPosition:ccp(input.gesturePanTranslation.x + originalPostion.x, originalPostion.y)];
            if(input.gesturePanTranslation.x > 70)
            {
                [View Select: [itemPanning tag]];

                SelectAttackCommand * command = [SelectAttackCommand new];
                command.SelectedAttack = [itemPanning tag];

                itemPanning = NULL;

                NOTIFY(command);
            }
        }
    }
    else if(![input gesturePanBegan] && itemPanning != NULL)
    {
        itemPanning = NULL;
        [View Open];
    }
4

1 に答える 1

1

これは答えですが、最善の答えではないかもしれません。KKInputGesture では、handlePanGesture の下で、翻訳の値は次のように計算されます。

GesturePanTranslation = [panRecognizer translationInView:glView]; GesturePanTranslation = [self convertRelativePointToGL:gesturePanTranslation];

ここでの 2 番目の呼び出しは、デバイスの向きに基づいて値を変換します。これはいくつかのシナリオでは問題ないかもしれませんが、私の場合は必要なかったのでコメントアウトしました.IPhone をどのように傾けても、翻訳値は常に正しいです.

ただし、ここで何かが欠けている可能性があるため、これをまだ回答としてマークしたくありません。

于 2012-12-22T05:35:46.423 に答える