Chapter    6

A Flying Ball

In this chapter, you will start organizing the source code of the Painter game a bit more. This is necessary because as you start adding more and more things to the game, the source code will become more complicated. You will explore using methods to structure the code more logically. You’ll conclude this chapter by adding a moving ball to the game.

Methods

You’ve already seen and used quite a few different kinds of methods and functions. For example, there is a clear difference between the UIColor.blackColor() method and the print() function: the latter one expects a parameter (a string), whereas the first one doesn’t. The blackColor method belongs to UIColor, as opposed to print, which is a standalone function. Additionally, ...

Get Swift Game Programming for Absolute Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.