gpt4 book ai didi

ios - cocos2D触摸屏崩溃

转载 作者:行者123 更新时间:2023-11-28 19:20:26 25 4
gpt4 key购买 nike

当执行这些代码块时,我的应用程序崩溃了。没有错误,只有警告。警告说,“'ccTouchesBegan:withEvent':'void'VS'BOOL'(又名'signed char')的实现中返回类型冲突”请帮忙。

-(BOOL) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
return YES;
}

-(BOOL) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *myTouch = [touches anyObject];
CGPoint point = [myTouch locationInView:[myTouch view]];
point = [[CCDirector sharedDirector] convertToGL:point];

CCNode *player = [self getChildByTag:kTagPlayer];
[player setPosition:point];

CCNode *computer = [self getChildByTag:kTagComputer];
[computer runAction:[CCMoveTo actionWithDuration:3.0
position:ccp(player.position.x, player.position.y)]
];

return YES;
}

最佳答案

正如您的警告所述,这些方法必须不返回任何内容 (void),而不是 bool 值。尝试更改它并查看它是否修复了警告,否则问题出在您的代码中,而不是这些方法的调用方式。

关于ios - cocos2D触摸屏崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9336603/

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