Reader small image

You're reading from  Swift Game Development - Third Edition

Product typeBook
Published inSep 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788471152
Edition3rd Edition
Languages
Right arrow
Authors (2):
Siddharth Shekar
Siddharth Shekar
author image
Siddharth Shekar

Siddharth Shekar is a game developer and teacher with over 6 years' industry experience and 12 years' experience in C++ and other programming languages. He is adept at graphics libraries such as OpenGL and Vulkan, and game engines such as Unity and Unreal. He has published games on the iOS and Android app stores. He has also authored books including Swift Game Development, Mastering Android Game Development with Unity, and Learning iOS 8 Game Development Using Swift, all published by Packt Publishing. He currently lives in Auckland, New Zealand, and is a lecturer in the games department at Media Design School. He teaches advanced computer graphics programming, PlayStation 4 native game development, and mentors final year production students.
Read more about Siddharth Shekar

Stephen Haney
Stephen Haney
author image
Stephen Haney

Stephen Haney has written two books on iOS game development. He began his programming journey at the age of 8 years on a dusty, ancient laptop using BASIC. He has been fascinated with building software and games ever since. Now well versed in multiple languages, he enjoys programming as a creative outlet the most. He believes that indie game development is an art forman amazing combination of visual, auditory, and psychological challengesrewarding to both the player and the creator. He enjoyed writing this book and sincerely hopes that it directly furthers your career or hobby.
Read more about Stephen Haney

View More author details
Right arrow

Spawning smashable crates that reward coins


To add smashable coin crates, we will create new crate sprites in our encounters using the scene editor. Follow these steps to add a Crate to the game:

  1. In Xcode, open one of the encounter scenes we created earlier in the book. I am using EncounterA.sks for this example. The scene will open in the Scene Editor. In the lower-right corner, click on the Media Library to see the media assets in your project.

  2. Locate the crate texture and drag it into your encounter.

  3. In the upper-right corner, click on the Custom Class Inspector and assign a Custom Class of Crate, as illustrated in the following screenshot:

  4. Repeat the process to create as many crates as you like. You can place them slightly above the ground and gravity will settle them into place.

You can always hold option and drag an existing sprite to create a clone with the same properties (persisting the Custom Class setting).

That is all you need to do to add smashable crates to the game. You can repeat...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Swift Game Development - Third Edition
Published in: Sep 2018Publisher: PacktISBN-13: 9781788471152

Authors (2)

author image
Siddharth Shekar

Siddharth Shekar is a game developer and teacher with over 6 years' industry experience and 12 years' experience in C++ and other programming languages. He is adept at graphics libraries such as OpenGL and Vulkan, and game engines such as Unity and Unreal. He has published games on the iOS and Android app stores. He has also authored books including Swift Game Development, Mastering Android Game Development with Unity, and Learning iOS 8 Game Development Using Swift, all published by Packt Publishing. He currently lives in Auckland, New Zealand, and is a lecturer in the games department at Media Design School. He teaches advanced computer graphics programming, PlayStation 4 native game development, and mentors final year production students.
Read more about Siddharth Shekar

author image
Stephen Haney

Stephen Haney has written two books on iOS game development. He began his programming journey at the age of 8 years on a dusty, ancient laptop using BASIC. He has been fascinated with building software and games ever since. Now well versed in multiple languages, he enjoys programming as a creative outlet the most. He believes that indie game development is an art forman amazing combination of visual, auditory, and psychological challengesrewarding to both the player and the creator. He enjoyed writing this book and sincerely hopes that it directly furthers your career or hobby.
Read more about Stephen Haney