Cocos2dx CCLabelAtlas字体与CCLabelTTF字体的使用方法

本文介绍了在Cocos2d-x中使用CCLabelAtlas和CCLabelTTF创建字体的方法。示例代码展示了如何创建动态显示分数的标签,包括设置字体、大小、位置、颜色等属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



1.26、字体

1、CCLabelAtlas字体

  示例代码:

    CCLabelAtlas*LBsocre4 = CCLabelAtlas::create(CCString::createWithFormat("%d", c)->getCString(), "labelatlasimg.png", 24, 32,'0');

                LBsocre4->setAnchorPoint(ccp(0,0.5));

                LBsocre4->setPosition(ccp(200,200));

               LBsocre4->setScale(0.7f);

                  LBsocre4->setString(CCString::createWithFormat("%d", c)->getCString());

               this->addChild(LBsocre4,5);

2、CCLabelTTF字体

   示例代码:

     CCLabelTTF*scoreLab = CCLabelTTF::create("0""Arial", 35);

               scoreLab->setPosition(ccp(a,b));

               scoreLab->setAnchorPoint(ccp(0, 1));

               scoreLab->setColor(ccc3(255,255,0));

               scoreLab->setString(CCString::createWithFormat("%d", c)->getCString());

                this->addChild(scoreLab, 2);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值