我试图添加一个10计数循环到我的游戏,但是当我运行代码时,它会生成一个“变量不可分配missing__block”错误消息。任何人都可以告诉我哪里错了,并指出我在正确的方向吗?变量不能分配missing__block
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint currentLocation = [[touches anyObject] locationInNode:self];
CGPoint previousLocation = [[touches anyObject] previousLocationInNode:self];
CGRect shipRect = _ship.frame;
if (CGRectContainsPoint(shipRect, previousLocation))
{
[self launch:10 p1:currentLocation p2:previousLocation rect1:shipRect];
}
}
-(void)launch:(int)count p1:(CGPoint) currentLocation p2:(CGPoint) previousLocation rect1:(CGRect) shipRect
{
CGPoint lvPosition = CGPointMake(_ship.position.x - (previousLocation.x - currentLocation.x), _ship.position.y);
_ship.position = lvPosition;
SKAction *sound = [SKAction playSoundFileNamed:@"slideup.mp3" waitForCompletion:NO];
SKAction *moveNode = [SKAction moveByX:lvPosition.x y:10.0 duration:3.0];
[_ship runAction: sound];
[_ship runAction: moveNode completion:^{[self launch:count-- p1:currentLocation p2:previousLocation rect1:shipRect];}]; /*variable not assignable missing__block error*/
}
更改参数是不好的主意,不管是否阻止,你都应该避免它 – sage444
你说你正在尝试添加一个循环,但是代码示例中没有循环。你错过了错误的东西吗? – CRD