Creating enemies
This game isn't simply an exploration game! We need to make this game intense and exciting!
Go ahead and import the Squiggy set of images that I've included, or again you can use your own.
In our GameLevelScene.m
file, we will add a new method to begin spawning random enemies. These ones will start off easy, but we will get into some baddies that will actually try to kill you!
Anyways, anywhere within the GameLevelScene.m
file, add the following method:
- (void)addSquiggy { SKSpriteNode * squiggy = [SKSpriteNode spriteNodeWithImageNamed:@"Squiggy"]; int minY = squiggy.size.height / 2; int maxY = self.frame.size.height - squiggy.size.height / 2; int rangeY = maxY - minY; int actualY = (arc4random() % rangeY) + minY; squiggy.xScale = -1.0; squiggy.position = CGPointMake(self.player1.position.x + 1000 + squiggy.size.width/2, actualY); squiggy.name = @"squiggy"; [self.map addChild:squiggy]; ...