Apple documentation says that subscript(_:)
is a method of SKNode.
https://developer.apple.com/reference/spritekit/sknode/1483070-subscript
The documentation also says that SKNode inherits from SKEffectNode, which inherits from SKNode. My beginner's understanding of this says that SKScene should have all the same methods available to it that an instance of SKNode would have.
However, in my GameScene subclass of SKScene, code hinting does not reveal the subscript method. If I try to use the method as follows, I get an error.
self.subscript("sensor")
Can anyone explain why this method seems to be unavailable? None of my research online has turned up any explanation.
subscript
is not a method of SKNode
. (Note that the documentation you linked does not say func subscript
.)
SKNode
has a subscript operator.
let sensorNodes: [SKNode] = self["sensor"]