Game Development Reference
In-Depth Information
7. Then we will change the screen background color to white using the
back-
groundColor
property in the following line of code.
self.backgroundColor = [SKColor colorWithRed:1.0
green:1.0 blue:1.0 alpha:1.0];
8. In the following line of code, we are creating a sprite object using the
spriteNodeWithImageNamed
method and passing the image name to the
same. Then we have positioned it to
100, 100
of the screen, which is in the
bottom-left corner of the screen. Then finally we have added it as a child.
self.ant = [SKSpriteNode
spriteNodeWithImageNamed:@"ant.jpg"];
self.ant.position = CGPointMake(100, 100);
[self addChild:self.ant];
Tip
Downloading the example code
You can download the example code files from your account at
http://www.packtpub.com
for all the Packt Publishing topics you have purchased. If you purchased this topic else-
where, you can visit
http://www.packtpub.com/support
and register to have the files e-
mailed directly to you.
In games, we have to keep two sets of images, one for the normal display and the second
for the retina display. In the preceding block of code, we have provided the name of the
sprite as
ant.jpg
, which is going to autoreference to
ant@2x.jpg
for the retina
devices.
Now build and run your application; you should see something similar to the following
screenshot: