Time for action – showing the game over scene
Use the following steps to create the game over scene:
- Open our Xcode project if it's not already open.
- Create a new Objective-C class inside the
GameScenes
group. - Call this class
GameOver
it should be a subclass ofScene
. - Switch to the
GameOver.h
file. - Using the following line of code, add a property called
message
:@property SPTextField *message;
- Using the following line of code, add another property to indicate whether the game was won:
@property (nonatomic) BOOL gameWon;
- Switch to
GameOver.m
. - Import the
SceneDirector.h
,Assets.h
, and theWorld.h
files, as shown in the following code:#import "SceneDirector.h" #import "Assets.h" #import "World.h"
- Add an initializer for this new scene, as shown in the following code:
-(id) init { if ((self = [super init])) { SPImage *background = [SPImage imageWithTexture:[Assets texture:@"water.png"]]; _message = [SPTextField textFieldWithWidth...