不兼容的块指针SKSpriteNode

这是我的代码

- (void) update:(NSTimeInterval)currentTime { [self.children enumerateObjectsUsingBlock:^(SKSpriteNode * child, NSUInteger idx, BOOL *stop) { child.position = CGPointMake(child.position.x-self.scrollingSpeed, child.position.y); if (child.position.x <= -child.size.width){ float delta = child.position.x+child.size.width; child.position = CGPointMake(child.size.width*(self.children.count-1)+delta, child.position.y); } }]; } 

我得到一个错误

 Incompatible block pointer types sending 'void (^)(SKSpriteNode *__strong, NSUInteger, BOOL *)' to parameter of type 'void (^ _Nonnull)(SKNode * _Nonnull __strong, NSUInteger, BOOL * _Nonnull)' 

我不知道为什么。 我试图改变它到SKNode但它说尺寸不存在。

任何想法将不胜感激。

枚举块语法不正确,您需要更改:

  [self.children enumerateObjectsUsingBlock:^(SKSpriteNode * child, NSUInteger idx, BOOL *stop) { child.position = CGPointMake(child.position.x-self.scrollingSpeed, child.position.y); if (child.position.x <= -child.size.width) { float delta = child.position.x+child.size.width; child.position = CGPointMake(child.size.width*(self.children.count-1)+delta, child.position.y); } }]; 

  [self.children enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) { SKSpriteNode *child = (SKSpriteNode *)object; child.position = CGPointMake(child.position.x-self.scrollingSpeed, child.position.y); if (child.position.x <= -child.size.width) { float delta = child.position.x+child.size.width; child.position = CGPointMake(child.size.width*(self.children.count-1)+delta, child.position.y); } }]; 

枚举块的第一个参数是typesid不是SKSpriteNode 。 NSArray没有这样的实现。