加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – Coco2d – 使用CCBitmapFontAtlas

发布时间:2020-12-14 17:45:06 所属栏目:百科 来源:网络整理
导读:我正在尝试使用COCO2d创建一个简单的游戏但到目前为止没有运气… 当我试图创建一个CCBitmapFontAtlas我得到一个错误说: “_OBJC_CLASS _ $_ CCBitmapFontAtlas”,引自:“ 并且 : “’CCBitmapFontAtlas’已被弃用” 这是我的头文件: @interface MainMenu
我正在尝试使用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"];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读