我使用kobold2d的KKInput使用平移手勢識別器進行拖放操作。當iphone平放在桌面上時,它的工作原理是完美的,但如果我將手機向我傾斜,翻譯似乎完全錯誤,並且不再正常運行,實際上它似乎認爲我的iPhone是顛倒的,我認爲。KKInput panningGesture在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];
}
我已經註釋掉gesturePanTranslation - = [self convertRelativePointToGL:gesturePanTranslation]; - 它仍然不能解決我的同樣的問題......呵? – Clev3r
傾斜電話仍然打破你的平移? – AwDogsGo2Heaven
是的。我認爲這可能是一個問題,我如何根據平移來改變我的對象。請參閱:http://stackoverflow.com/questions/14668685/improper-iphone-orientation/14670540#14670540如果你想幫助。 – Clev3r