Use the Game Loop to Apply Game Logic
In SpriteKit, the game loop is handled with a series of frame-cycle events. These events, in the order in which they occur, are as follows:
-
The update(_:) method is called. This method gets called once per every frame and is the main method you’ll use to execute your game logic.
-
SKScene evaluates the actions. At this point, your scene processes all of the actions it needs to process.
-
The didEvaluateActions() method is called. This method gets called after all of the actions for the frame are processed.
-
SKScene simulates physics. At this point, your scene processes all of the physics on nodes with attached physics bodies.
-
The didSimulatePhysics() method is called. This method gets called after all of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access