【发布时间】:2024-01-18 19:12:01
【问题描述】:
这是我的 ccTouchesMoved 方法。 怎么了?我使用 cocos2d 框架。
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CCNode *sprite = [self getChildByTag:kTagPlayer];
CCNode *sprite2 = [self getChildByTag:kTagEnemy];
CGPoint point;
//Собрать все касания.
NSSet *allTouches = [event allTouches];
for (UITouch *touch in allTouches)
{
point = [touch locationInView:[touch view]];
point = [[CCDirector sharedDirector] convertToGL:point];
if (point.y > 384)
{
if (point.x > 992)
sprite2.position = ccp(992, size.height - 100);
else if (point.x < 32)
sprite2.position = ccp(32, size.height - 100);
else
sprite2.position = ccp(point.x, size.height - 100);
}
else
{
if (point.x > 992)
sprite.position = ccp(992, 100);
else if (point.x < 32)
sprite.position = ccp(32, 100);
else
sprite.position = ccp(point.x, 100);
}
}
}
【问题讨论】:
-
你确定你的意思是 point.x > 992?这看起来相当大,而且只能在 iPad 屏幕上工作。即使这样,考虑到 1024 的最大宽度(横向模式),这仍然是一个非常小的触摸区域。
标签: iphone cocos2d-iphone multi-touch