O'Reilly logo

Beginning iOS Game Development by Patrick Alessi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6

Drawing with UIKit and Core Graphics

What You Will Learn In This Chapter:

  • Exploring the basics of the UIKit and Core Graphics drawing frameworks
  • Learning about the iOS drawing environment
  • Drawing shapes with UIBezierPath
  • Specifying colors with UIColor
  • Drawing shadows and gradients with Core Graphics
  • Working with images
  • Animating a game with CADisplayLink
  • Building a complete, animated, graphical game

In the first section of the book, you learned about the tools that you needed to get started building games for iOS. These included the Xcode programming environment, the C and Objective-C languages, and the Cocoa Foundation framework. Now that you have a solid foundation in the basics, you are ready to move on to the next level of tools. In this chapter, you will learn about some of the APIs that iOS provides for drawing graphics.

Introducing the Drawing Frameworks

There are two principal methods for drawing graphics in iOS. First, you can use the native drawing technologies in the UIKit and Core Graphics frameworks. These frameworks provide an object-oriented way to work with 2D graphics and images. You will be using these tools in this chapter to play with some samples and to build the example game, Blocker.

Blocker is a simple block-breaking game as you can see in Figure 6.1. The object of Blocker is to break all of the blocks at the top of the screen by hitting them with the ball. You must prevent the ball from going off the bottom of the screen by using the paddle. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required