嘿,我有一些代码不断返回错误消息,但我无法弄清楚问题是什么。我对 Objective-c 语法相当陌生,所以它可能相当简单,但我似乎找不到问题所在。方法是
-(void)setPlayerPosition:(CGPoint) position {
CGPoint tileCoord = [self tileCoordForPosition:position];
int tileGid = [metaLayer tileGIDAt:tileCoord];
if (tileGid) {
NSDictionary *properties = [tileMap propertiesForGID:tileGid];
if (properties) {
NSString *collision = [properties valueForKey:@"Collidable"];
if (collision && [collision compare:@"True"] == NSOrderedSame) {
return;
}
NSString *collectable = [properties valueForKey:@"Collectable"];
if (collectable && [collectable compare:@"True"] == NSOrderedSame) {
[metaLayer removeTileAt:tileCoord];
[foreground removeTileAt:tileCoord];
}
}
}
player.position = position;
}
它返回错误 Invalid initializer for the 2nd line 并且还说我的班级可能不会响应 'tileCoordForPosition:' 任何帮助将不胜感激!