精灵没有出现

时间:2015-12-18 08:21:48

标签: ios swift sprite-kit sprite

我有一个定义的精灵,当我运行应用程序时它没有出现。这是我的代码和一些图像,以帮助找出错误:

import SpriteKit

class GameScene: SKScene {

    var SingleplayerButton: SKSpriteNode! = nil

    override func didMoveToView(view: SKView) {

        SingleplayerButton = SKSpriteNode(imageNamed: "Unknown")
        SingleplayerButton.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
        SingleplayerButton.size = CGSize(width: 200, height: 50)

    }

    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {

        for touch: AnyObject in touches {

            let location = touch.locationInNode(self)

            if SingleplayerButton.containsPoint(location) {



            }

        }

    }

}

enter image description here

1 个答案:

答案 0 :(得分:1)

你遗忘了addChild到你的场景