0
这必须是一个相当简单的解决方案,我只是想念。如何使用KKInput实现简单的拖放操作?如何使用KKInput实现在Kobold2d中的拖动?
我想在更新方法中这样的东西。
KKInput* input = [KKInput sharedInput];
if ([input touchesAvailable]){
if ([input isAnyTouchOnNode:[self getChildByTag:0] touchPhase:KKTouchPhaseAny]) {
[sprite setPosition:[input locationOfAnyTouchInPhase:KKTouchPhaseAny]];
}
}
它工作正常,但有两个问题。 1.你可以通过移动真正的快速和2来避开拖动。如果拖动精灵下面的标签,它抓住了那个。
我错过了什么?
触摸开始于精灵:设置拖动标志,记住精灵。移动事件=更新精灵pos以触摸pos。触摸结束:清除拖动标志。 – LearnCocos2D 2013-03-17 20:50:36
我的歉意,你能解释一下设置拖动标志的过程吗?仍然在这里失去。谢谢你回答Steffen。 – Hartix 2013-03-18 00:10:43
dragging = YES; ;) – LearnCocos2D 2013-03-18 00:25:33