2

更新到 swift3 后,注释行返回错误:Property 'entity' with type 'GKEntity!' (又名“ImplicitlyUnwrappedOptional”)不能覆盖类型为“GKEntity?”的属性

import SpriteKit
import GameplayKit
class EntityNode: SKNode {  
    weak var entity: GKEntity!    // error here
}

在升级之前它运行良好。知道什么是错的以及如何解决这个问题吗?

4

1 回答 1

4

SKNode已经有一个名为的属性entity,其定义如下:

var entity: GKEntity?

因此,您不能用您entity的类型覆盖它GKEntity!

因此,您可以将您的重命名entity为其他名称,也可以使用entity已经存在的名称。

你可以在这里阅读更多SKNode

希望对你有帮助:)

于 2016-09-14T06:20:11.543 回答