Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coco2d - using CCBitmapFontAtlas

i'm trying to create a simple game with COCO2d but no luck so far... when i'm trying to create a CCBitmapFontAtlas i get a error saying :

"_OBJC_CLASS_$_CCBitmapFontAtlas", referenced from:"

and also :

"'CCBitmapFontAtlas' is deprecated "

here is my header file:

@interface MainMenuScene : CCLayer 

{ CCBitmapFontAtlas* startNewGameLabel; }

  • (id) scene;

@end

and here is my implementation file :

#import "MainMenuScene.h"

@implementation MainMenuScene

  • (id) scene { CCScene scene = [CCScene node]; CCLayer layer = [MainMenuScene node]; [scene addChild:layer]; return scene;

}

-(id) init { if ((self = [super init])) { CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self); [self setVisible:YES];

     startNewGameLabel = [CCBitmapFontAtlas 
                          bitmapFontAtlasWithString:@"New Game" 
                          fntFile:@"bitmapfont.fnt"]; 
                                    //[CCLabelTTF labelWithString:@"New Game" 
                                    //                 fontName:@"AppleGothic" 
                                    //                 fontSize:48];
    CGSize size = [[CCDirector sharedDirector] winSize];
    startNewGameLabel.position = CGPointMake(size.width / 2, size.height / 2);
    [self addChild:startNewGameLabel];

}
return self;

}

  • (void) dealloc { CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);

    [super dealloc]; } @end

I created both .FNT file and .PNG file with heir

like image 894
Yaniv Avatar asked Feb 25 '23 09:02

Yaniv


2 Answers

You want CCLabelBMFont instead of CCBitmapFontAtlas.

startNewGameLabel = [CCLabelBMFont
                      labelWithString:@"New Game" 
                      fntFile:@"bitmapfont.fnt"]; 
like image 164
badgerr Avatar answered Feb 27 '23 23:02

badgerr


Use CCLabelBMFont instead. Will be removed 1.0.1

like image 36
Limotao Avatar answered Feb 27 '23 22:02

Limotao