I have a GameScene.sks
a custom class GameScene.swift
which is connected via the Custom Class Inspector (on the right in Xcode). This is working fine.
Now in the GameScene.swift
where I want to reference another scene that I want to reuse in many scenes in the future (oversimplified code):
class GameScene: SKScene {
// ...
override func didMove(to view: SKView) {
//...
guard let gameMenuPath = Bundle.main.path(
forResource: "GameMenu", ofType: "sks") else { return }
let url = NSURL(fileURLWithPath: gameMenuPath) as URL
let gameMenu = SKReferenceNode(url: url)
addChild(gameMenu)
//...
where I am loading a reusable GameMenu.sks
.
Everything works fine till here. Now the custom class issue for the GameMenu.sks
(the scene to be reused). For the GameMenu.sks
I also have a GameMenu.swift
which is referenced in the custom class inspector as custom class. So exactly as for the GameScene
. The problem is that it seems like the GameMenu.swift
is not found/loaded. I get no error - so it looks like I misspelled the custom class - but I checkt it many times and also cleared the Xcode cache.
Any ideas how to set custom class for a scene (.sks
) that is referenced in another scene?
I would think this is something that is done for reusable scene parts suche as the GameMenu
in my case that is visible in every GameScene
.
Thank you for any hints.