To display an image, we just need to follow these steps:
Inside the
Game
initializer method, add the following piece of code:SPImage* image = [SPImage imageWithTexture:[Assets texture:@"Default.png"]];
At the bottom of the initializer method, add the image to the display tree of the
Game
class.Run the example, and you will see the following:
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...