Coco2d - using CCBitmapFontAtlas

I am trying to create a simple game with COCO2d, but so far no luck ... when I try to create CCBitmapFontAtlas, I get an error message:

"_ OBJC_CLASS _ $ _ CCBitmapFontAtlas" referenced by: "

and:

"'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 level = [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 the .FNT and .PNG file with the heir

+4
source share
2 answers

You want CCLabelBMFont instead of CCBitmapFontAtlas.

 startNewGameLabel = [CCLabelBMFont labelWithString:@"New Game" fntFile:@"bitmapfont.fnt"]; 
+7
source

Use CCLabelBMFont instead. It will be deleted 1.0.1

+1
source

Source: https://habr.com/ru/post/1335561/


All Articles