Game Development Reference
In-Depth Information
Listing 16-4 shows the HelloWorldLayer implementation in its entirety. Apart
from the previous call to KKConfig and the use of the CCDirector extensions and
platform macros discussed earlier, it's still 100-percent cocos2d code.
Listing 16-4 . Hello Kobold2D Implementation File
#import "HelloWorldLayer.h"
@implementation HelloWorldLayer
@synthesize helloWorldString, helloWorldFontName;
@synthesize helloWorldFontSize;
-(id) init
{
if ((self = [super init]))
{
CCDirector* director = [CCDirector sharedDirector];
CCSprite* sprite = [CCSprite spriteWithFile:@"ship.png"];
sprite.position = director.screenCenter;
[self addChild:sprite];
// get the hello world string from the config.lua file
[KKConfig injectPropertiesFromKeyPath:@"HelloWorldSettings" target:self];
CCLabelTTF* label = [CCLabelTTF labelWithString:helloWorldString
fontName:helloWorldFontName
fontSize:helloWorldFontSize];
label.position = director.screenCenter;
label.color = ccGREEN;
[self addChild:label];
// print out which platform we're on
NSString* platform = @"(unknown platform)";
if (director.currentPlatformIsIOS)
{
// add code
platform = @"iPhone/iPod Touch";
 
 
Search Nedrilad ::




Custom Search