Chapter     5

More Animated Sprites: “Enemies” and “Bonuses”

The Opposition

So far, this game is a solo endeavor of running and jumping endlessly without any apparent objective. In the words of my little cousin, “It’s lame!” That’s just a wee bit pessimistic, but it is a fairly accurate assessment.

Well, it’s time to change all that. In this chapter, you’ll generate some bad guys to liven things up a bit.

Before doing so, you need to move some code around to increase readability and organization. You’ll pull the ledge and brick base creation out of the initWithSize method and into a separate method called createSceneContents, which is located in the SKBGameScene.m file and inserted immediately below initWithSize:

        [self addChild:backdrop]; ...

Get Learn Sprite Kit for iOS Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.