Game Development Reference
In-Depth Information
class. Listing 7-8 updates the scene method to add the new InputLayer to it, and
both layers get a tag just in case you need to identify them later.
Listing 7-8. Adding the InputLayer to the GameScene
#import "InputLayer.h"
...
+(id) scene
{
CCScene* scene = [CCScene node];
GameScene* layer = [GameScene node];
[scene addChild:layer z:0 tag:GameSceneLayerTagGame];
InputLayer* inputLayer = [InputLayer node];
[scene addChild:inputLayer z:1 tag:GameSceneLayerTagInput];
return scene;
}
The new tags are defined in the GameLayer header file just above the existing
GameSceneNodeTags enum as follows:
typedef enum
{
GameSceneLayerTagGame = 1,
GameSceneLayerTagInput,
} GameSceneLayerTags;
With the InputLayer in place, the next step is to add the header files for the Sneak-
yInput files you want to use to the InputLayer.h header file. I'm not picky, and
you're probably going to use most of the classes, so just add all the SneakyInput header
files:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "GameLayer.h"
#import "Ship.h"
// SneakyInput headers
 
 
Search Nedrilad ::




Custom Search