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, ...
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