Is it possible to create a protocol like this:
protocol SetupProt {
func setup()
}
then at the end of my didMove function, tell the app to run all the setup functions from all the subclasses that implement this protocol?
Or will I need to store references to all these objects that are implementing the protocol and iterate through them?
Currently I have that protocol in use right now.
Then I have a global array like this:
setups = [SetupProt] = []
I have subclass for "a platform" in my game. I subclass it in the XCODE editor. And within the aDecoder init function, I add that node to this global array...
I do this because the scene property is nil at this moment, so I can't access it yet, it hasn't finished loading I"m guessing.
At the end of my scenes didMove, I iterate through this array:
for set in setups { set.setup() }
And this gets the job done.
I'm wondering if instead of storing an array of all these objects, can I just tell the app: "Hey, run the setup function for anything that is implementing this protocol.