我正在尝试使用COCO2d创建一个简单的游戏但到目前为止没有运气…
当我试图创建一个CCBitmapFontAtlas我得到一个错误说:
当我试图创建一个CCBitmapFontAtlas我得到一个错误说:
“_OBJC_CLASS _ $_ CCBitmapFontAtlas”,引自:“
并且 :
“’CCBitmapFontAtlas’已被弃用”
这是我的头文件:
@interface MainMenuScene : CCLayer
{
CCBitmapFontAtlas * startNewGameLabel;
}
>(id)场景;
@结束
这是我的实现文件:
#import "MainMenuScene.h"
@implementation MainMenuScene
>(id)场景
{
CCScene scene = [CCScene node];
CCLayer layer = [MainMenuScene node];
[scene addChild:layer];
回归场景;
}
– (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(@“%@:%@”,self);
[super dealloc];
}
@结束
解决方法
你想要
CCLabelBMFont而不是CCBitmapFontAtlas.
startNewGameLabel = [CCLabelBMFont labelWithString:@"New Game" fntFile:@"bitmapfont.fnt"];