In a SpriteKit scene, a number of methods are called automatically by the system and you can override them in your game scene to implement custom behavior. For example:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for t in touches { self.touchDown(atPoint: t.location(in: self)) }
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
override func didFinishUpdate() {
// Do some stuff immediately before rendering
}
Apple's documentation for SpriteKit has this helpful graphic which shows the order in which these methods are called during each frame:
However, this discussion does not include any of the touch events, such as touchesBegan(_:with:). I'm trying to figure out at what point these touch events are called in relation to the other events in SpriteKit's frame cycle. I can't find any Apple documentation that gives an answer.
The only mention I could find was at the doc linked above, which says:
The scene’s
update(_:)method is called with the time elapsed so far in the simulation. This is the primary place to implement your own in-game simulation, including input handling, artificial intelligence, game scripting, and other similar game logic. Often, you use this method to make changes to nodes or to run actions on nodes.
Although it says that the update(_:) method is the place to implement input handling, that seems a bit misleading, as it's common practice to use the touch event methods like touchesBegan(_:with:) to capture touch input on iOS. SKScene inherits these touch method as a subclass of UIResponder (SKScene > SKEffectNode > SKNode > UIResponder). But I'm trying to determine when those methods are called within the order of the scene's frame-cycle events. This can be important to know when you are trying to make certain touch-dependent things happen in a specific order within your scene's frame cycle.
My guess would be that the touch methods are called at the start of the frame cycle, just prior to when the update(_:) method is called. But I'm looking for a more definitive answer than just my hunch.

