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 – displaying an image


To display an image, we just need to follow these steps:

  1. Inside the Game initializer method, add the following piece of code:

    SPImage* image = [SPImage imageWithTexture:[Assets texture:@"Default.png"]]; 
  2. At the bottom of the initializer method, add the image to the display tree of the Game class.

  3. Run the example, and you will see the following:

What just happened?

As we already know, we need the SPImage class to display a texture. It can be compared to SPQuad, but instead of just displaying a color, it displays the texture on itself. We used the Assets class to get our Default.png image from the Resources folder.

In the next step, we added the image to the display tree of our game class using the addChild method. Running the example we should see that our cardboard puppet doll is not visible anymore because the black image we just loaded is displayed on top of the cardboard puppet doll.

Our Game.m file should have the following content:

#import "Game.h" 
#import...