如何解决此Sprite Kit(Swift3)错误?

时间:2017-06-21 05:53:02

标签: ios swift compiler-errors

import SpriteKit
extension GameScene {

    func addPlayer() {
        player = SKSpriteNode(color: UIColor.red , size: CGSize(width: 50, height: 50))

这显示错误

  

无法指定类型' SKSpriteNode'的值输入' SKSpriteNode!.Type' (又名' ImplicitlyUnwrappedOptional< SKSpriteNode> .Type')

1 个答案:

答案 0 :(得分:0)

像这样定义你的玩家:

var player = SKSpriteNode(imageNamed: "YourImageForTheNode")
// or just...
var player = SKSpriteNode()