iphone – Coco2d – 使用CCBitmapFontAtlas

前端之家收集整理的这篇文章主要介绍了iphone – Coco2d – 使用CCBitmapFontAtlas前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用COCO2d创建一个简单的游戏但到目前为止没有运气…
当我试图创建一个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];
}
@结束

我用继承人创建了.FNT文件和.PNG文件

解决方法

你想要 CCLabelBMFont而不是CCBitmapFontAtlas.

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

猜你在找的Xcode相关文章