我正在sprite工具包(objective-c)中的Xcode项目上工作,但遇到此错误,我不知道如何解决,但我试图让两个节点发生冲突时进行记录。
iOS SKSpriteNode错误:
assigning to 'skspritenode *const __strong' from incompatible type 'CGRect' (aka 'struct CGRect')
我的代码在这里:
//This is the .m file
-(void) Clouds{
SKSpriteNode* character = [BBCharacter spriteNodeWithImageNamed:@"character1"];
[self enumerateChildNodesWithName:@"cloud1" usingBlock:^(SKNode *node, BOOL *stop) {
if (node.position.x < -380 || node.position.y < 0){ //node.position.x < -380
[node removeFromParent];
NSLog(@"DELETE");
}
else{
node.position = CGPointMake(node.position.x - 1, node.position.y);
}
if (CGRectIntersectsRect (character, cloud1)) {
NSLog(@"Intersection");
}
}];
}
//This is the .h file
@interface{
}
@property (nonatomic, strong) BBCharacter *playerSprite;
@end
我跳过了很多东西,可能拼写错了...谢谢!麦可
我同意您需要从基础开始,但似乎注释已指出您要使用框架来获取CGRects。因此,上面的代码看起来有两个问题:
因此,可以在场景中添加角色:
[self addChild: character];
或者使角色成为场景中已经存在的其他事物的指针:
character = [self childNodeWithName:@"character"];
character = self.playerSprite; //etc
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句