How do I compose a touchesBegun command in a StartButton class that calls start() in the scene any instance of itself has been placed in?
I know... probably OOP 101. But well beyond me, today.
UPDATE:
Here is how I currently (partially) solve the problem. It doesn't feel right, but it works, somewhat. Not as much as I'd like:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
SoundManager.playSceneStartSound()
run(ready)
if CEO.startButtonIsActive{
print("We're STARTING NOW...")
if let menuScene = self.scene as? Menu_Memory {
menuScene.startTheGame()
}
else
if let menuScene = self.scene as? Menu_Chaser {
menuScene.startTheGame()
}
else
if let menuScene = self.scene as? Menu_Picker {
menuScene.startTheGame()
}
else
if let menuScene = self.scene as? Menu_Q_AndA {
menuScene.startTheGame()
}
else
{print("Houston, we have a problem... no gameScene")}
}
else
{
print("You still have some preparation to do, amigo!")
}
}
Alternatively, the ability to pass a Class Type would be helpful too. This is almost a separate question, but for the fact I think they're very closely related, perhaps.
At any rate: in a button, trying to create a reference to a class type, I've tried a bunch of variations, with no luck.
Some of my ridiculous attempts, all fail:
Menu_Memory is a SKScene
var menuClass01: Menu_Memory.self
var menuClass02: AnyClass = Menu_Memory.self
var menuClass03: AnyClass = Menu_Memory(self)
var menuClass04: AnyClass as! Menu_Memory.self
var menuClass05: AnyClass as! Menu_Memory(self)