In this 5-part Scene Kit tutorial series, you’ll learn how to make your first 3D iOS game: a game like Fruit Ninja called Geometry Fighter!
By Chris Language.
To color your random object, you modify materials on geometry; this line gets the first available material of geometry and sets the diffuse property’s contents to a random UIColor. The random() method on UIColor is another helper defined as an extension inside the game utilities.
Note: You’ll learn more about materials and their properties in Section II of this book. The takeaway here is that you can assign a UIColor to the diffuse property’s content in order to change the object’s color.
Finally, build and run your game to see a beautifully colored object:
Wouldn’t it be neat if you could spawn more than one object? You’ll fix this…in the next part of the series! :]
Where To Go From Here?
Here is the example code from this Scene Kit tutorial with Swift.
At this point, you should keep reading to the fourth part of this tutorial series, where you’ll learn how to make geometry spawn over time using the Scene Kit render loop.
If you’d like to learn more, you should check out our book 3D iOS Games by Tutorials. The book teaches you everything you need to know to make 3D iOS games, by making a series of mini-games like this one, including a games like Breakout, Marble Madness, and even Crossy Road.
In the meantime, if you have any questions or comments about this tutorial, please join the forum discussion below!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.