gpt4 book ai didi

iphone - 多点触控在 cocos2d 中不起作用

转载 作者:行者123 更新时间:2023-12-03 20:26:18 25 4
gpt4 key购买 nike

这是我的 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);
}
}

}

最佳答案

您是否在 glView 中启用了多次触摸?默认情况下,glView 在应用程序委托(delegate)中实例化。代码如下。

[glView setMultipleTouchEnabled:YES];

关于iphone - 多点触控在 cocos2d 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4793659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com