Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – changing the background color


Let's take a look at the required steps to change the background color:

  1. Open our Xcode game template if it's not already open.

  2. Open the Game.m source file.

  3. After the initialization method and before the existing SPQuad object, add the following lines:

    SPQuad *background = [SPQuad quadWithWidth:Sparrow.stage.width height:Sparrow.stage.height color:0xffffff];
    [self addChild:background];
  4. Run the example.

When the example is running, we see our red rectangle on a white background as shown in the following screenshot:

What just happened?

In step 1, we opened our Xcode template that we created in the previous chapter, and in step 2, we navigated to the Game.m file, which is where our game code currently lies. The game is the red rectangle that keeps showing up.

In step 3, right before we drew our red rectangle, we defined the background variable that is a pointer to an instance of SPQuad. The SPQuad class is derived from SPDisplayObject. The function of...