1
我有一个工作和编译Swift游戏,我更新到新的XCode之前,突然出现了很多错误。这里有两个我无法修复。Swift:SKNode应该有可选的类型,可选成员没有成员
func centerOnNode(node: SKNode) {
let cameraPositionInScene = node.scene?.convertPoint(node.position, fromNode: node.parent!)
var y = CGFloat(node.parent?.position.y - cameraPositionInScene?.y!)
// ERROR:
// Operand of postfix ‘!’ should have optional types; Type is CGFLoat
let x = CGFloat(node.parent.position.x - cameraPositionInScene.x)
// ERROR:
// SKNode? does not have a member position
// push the camera a bit up
y -= 75
node.parent.position = CGPointMake(x, y)
我想我真的不明白这一点!和?商业。包装,解包,可选类型。这是Java还是C#术语?