Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
iOS Game Development By Example

You're reading from   iOS Game Development By Example Learn how to develop an ace game for your iOS device, using Sprite Kit

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher Packt
ISBN-13 9781785284694
Length 220 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Samanyu Chopra Samanyu Chopra
Author Profile Icon Samanyu Chopra
Samanyu Chopra
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. An Introduction to Sprite Kit FREE CHAPTER 2. Scenes in Sprite Kit 3. Sprites 4. Nodes in Sprite Kit 5. Physics in Sprite Kit 6. Animating Sprites, Controls, and SceneKit 7. Particle Effects and Shaders 8. Handling Multiple Scenes and Levels 9. Performance Enhancement and Extras 10. Revisiting Our Game and More on iOS 9 Index

Simulating physics in Sprite Kit


Most of the game engines have an inbuilt physics engine, and you can also add an external physics engine to a game engine. Fortunately, Apple provides a physics engine in Sprite Kit. In Sprite Kit, physics properties are applied by an object of the class, SKPhysicsBody. As we have already learned that objects are connected to a node in a node tree, physics simulation uses a node's orientation and position for simulation. In Sprite Kit, when a game renders, each frame invokes some functions in a cycle, as follows:

update
didEvaluateActions
didSimulatePhysics
didApplyConstraints
didFinishUpdate

After actions (such as image changing in a node for animation) SKScene simulates physics to do all the actions, such as gravity on a physics body, velocity change, collision between two physics bodies, and so on. If we go through our SKNode class, we will see there is a property called physicsBody. It takes the SKPhysicsBody object as a parameter and defines physics laws...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime