Game Development Reference
In-Depth Information
How to do it
Now we have our working sample project and we need to update the game template project
to get started with code game logic. Perform the following steps to start working with the
basic code flow for the game:
1. Open the GameViewController.m file and update the viewDidLoad meth-
od; remove all the code from this class and make it look something similar to the
following lines of code:
- (void)viewDidLoad {
[super viewDidLoad];
// Configure the view.
SKView * skView = (SKView *)self.view;
skView.showsFPS = YES;
skView.showsNodeCount = YES;
// Create and configure the scene.
SKScene * scene = [GameScene
sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
}
2. Open the GameScene.m file; this class creates a scene, which will be plugged in-
side the game. Now, remove all the codes from this class and just add the follow-
ing function:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
self.backgroundColor = [SKColor colorWithRed:0.15
green:0.15 blue:0.3 alpha:1.0];
}
}
3. Now, compile and run the app; you should be able to see the background image
correctly. This will look something similar to the following screenshot:
Search WWH ::




Custom Search