Let's take a look at the required steps to change the background color:
Open our Xcode game template if it's not already open.
Open the
Game.m
source file.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];
Run the example.
When the example is running, we see our red rectangle on a white background as shown in the following screenshot:
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...