学习4-Cocos2D-X UI系统

已经学了好几节了,现在把UI系统的笔记再整一下。

Cocos2D-X UI系统我学习的有:字体、标签、菜单、进度条、计时器。

1、字体

2、标签

3、菜单

4、进度条

5、计时器

其实小牛在写这个笔记的时候,已经把cocos2dx的基础篇学习完了,现在就当是做一个基础巩固。
其实小牛是个菜鸟……尴尬

小牛在认识系统中基础UI的时候,用了几个字体标签的组件:

<span style="white-space:pre">	</span>CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* ttfFont = CCLabelTTF::create("Hello World", "Arial", 24);
	addChild(ttfFont);
	ttfFont->setPosition(ccp(s.width/2,s.height/2));
	ttfFont->setString("Hello cocos2dx");
	ttfFont->setColor(ccc3(255,0,0));
	ttfFont->setScale(3.0f);
	ttfFont->setRotation(45.f);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelBMFont* bmfFont = CCLabelBMFont::create("1234", "fonts/bitmapFontChinese.fnt");
	addChild(bmfFont);
	bmfFont->setPosition(ccp(s.width/2,s.height/2));
	bmfFont->setColor(ccc3(255,0,0));
	//bmfFont->setScale(3.0f);
	//bmfFont->setRotation(45.f);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelAtlas* atlasFont = CCLabelAtlas::create("123","fonts/labelatlas.png",32,32,96);
	addChild(atlasFont);
	atlasFont->setPosition(ccp(s.width/2,s.height/2));
	
其中本来想写中文,可发现中文显示出来的都是乱码,后来在百度上查了一下中文的问题,发现是个很麻烦的问题,解决办法点这里

小牛也是水平太low了,没有实现就往下学习了。

小牛在csdn这个强大的blog中找到各种优秀文章,在此就做一个记录咯! 

进度条的使用-> 点这里

小牛也是着急,这做个小游戏怎么这么难…… 奋斗 奋斗


CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* ttfFont = CCLabelTTF::create("Hello World", "Arial", 24);
	addChild(ttfFont);
	ttfFont->setPosition(ccp(s.width/2,s.height/2));
	ttfFont->setString("Hello cocos2dx");
	ttfFont->setColor(ccc3(255,0,0));
	ttfFont->setScale(3.0f);
	ttfFont->setRotation(45.f);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelBMFont* bmfFont = CCLabelBMFont::create("1234", "fonts/bitmapFontChinese.fnt");
	addChild(bmfFont);
	bmfFont->setPosition(ccp(s.width/2,s.height/2));
	bmfFont->setColor(ccc3(255,0,0));
	//bmfFont->setScale(3.0f);
	//bmfFont->setRotation(45.f);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelAtlas* atlasFont = CCLabelAtlas::create("123","fonts/labelatlas.png",32,32,96);
	addChild(atlasFont);
	atlasFont->setPosition(ccp(s.width/2,s.height/2));
	
用起来有些不顺手,毕竟第一次使用……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值