I am new to Swift and I am trying to encode a simple game using SpriteKit.
I am trying to create a main menu page for the start button.
I created a file .sksand .swift(cocoa touch class) with the same name.
I designed .sksas I want, but the cocoa touch class does not work.
.swift:
import SpriteKit
class MenuScene: SKScene {
var mStartBtn: SKSpriteNode = SKSpriteNode()
var mLabel: SKLabelNode = SKLabelNode()
override func didMove(to view: SKView) {
mStartBtn = self.childNode(withName: "startBtn") as! SKSpriteNode
mLabel = self.childNode(withName: "label") as! SKLabelNode
mLabel.text = "Hello.."
}
}
I tried to change the label on the screen to see if it works, but it will not change, as if the .swift file did not work / was not connected to the .sks file.
source
share