【发布时间】:2013-04-07 04:41:22
【问题描述】:
目前,我有一个益智游戏,其中一些对象可以使用 ccTouchesBegan && ccTouchesMoved 方法移动
在 ccTouchesBegan 中调用:
if (CGRectContainsPoint(newBoundingBox, touchLocation))
{
//Set the selectedSprite to the sprite with newBoundingBox
}
然后在 ccTouchesMoved 我做:
CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
newPos = ccpAdd(selSprite.position, translation);
selectedSprite.position = newPos;
现在这一切都很好而且花花公子,但是,我移动的一些对象大约是 140x40px(在 320x480 iPhone 上),有时 ccTouchesBegan 方法不会识别包含 touchLocation 的 boundingBox。
我的问题是,我可以增加对象的边界框的大小,这样如果用户“错过”触摸一点点,它会帮助他们吗?需要您在触摸屏上如此精确地移动障碍物,这有点令人沮丧。
编辑:对于 iPhone:
我如何获得 touchLocation,这是在 ccTouchesBegan 中:
NSSet *touchSet = [event allTouches];
int numberOfTouches = [touchSet count];
CGPoint touchLocation = [self convertTouchToNodeSpace:[touches anyObject]];
allTouches 在触摸开始时自动传递。
【问题讨论】:
-
哦,最小的精灵是 98x28px,28px 太窄了,不能用手指连续移动
-
我有点好奇,想知道您是如何获得 touchLocation 的?你能把代码..
标签: iphone ios xcode cocos2d-iphone box2d