I created a main menu scene view after GameScene is done. GameScene worked fine by itself. However it doesn't show up in the center after it's transferred from the main menu scene view. Both sks files have the same width and height dimensions and anchor points. Why is that?
class Menu: SKScene {
var newGameButtonNode: SKSpriteNode?
var bossFightButtonNode: SKSpriteNode?
var highScoreLabelNode: SKLabelNode?
override func didMove(to view: SKView) {
newGameButtonNode = self.childNode(withName: "newGameButton") as? SKSpriteNode
bossFightButtonNode = self.childNode(withName: "bossFightButton") as? SKSpriteNode
highScoreLabelNode = self.childNode(withName: "highScoreLabel") as? SKLabelNode
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
//set touch to self
let touch = touches.first
if let location = touch?.location(in: self) {
let nodesArray = self.nodes(at: location)
if nodesArray.first?.name == "newGameButton" {
let transition = SKTransition.flipHorizontal(withDuration: 0.5)
let gameScene = GameScene(size: self.size)
gameScene.scaleMode = .aspectFill
self.view?.presentScene(gameScene, transition: transition)
}
}
}
}