Label :
Line Heght :每行高度
Node的H :整体高度
OverFlow:None 一行
CLAMP :改变Node的w 改变宽度 ,只有一行
SHRINK :根据Node的w和h 自动缩放 不可以修改其他属性
RESIZEHEIGHT:根据Node的w自动换行 可以修改其他属性
using System :使用系统字库
Font : TTF 字库 缺点 自定义字库文件占资源
位图字库描述文件 fnt +图片 传入的是图片文件
字体制作工具
Label扩展:
锚点为(0,0.5) :向右扩展 ,
(0.5,0.5)中点左右扩展
在cocosCreator:在资源管理器中加入图片即可以转化成精灵格式
添加图集资源:plist+png
富文本:RichText
富文本添加图片:1添加图集,2文本标签
1: 添加富文本组件;
2: 设置富文本的字符内容;
<color=#0fffff>Text</color> 指定文字的颜色;
<img src='cow1_1'/> img标签,文本插入图片,图片要在指定的图集里面;
u: 给文本加下划线
i: 用斜体来渲染, b: 用粗体来渲染
size: 指定字体渲染大小,大小值必须是一个整数 <size=30>enlarge me</size>
outline: 设置文本的描边颜色和描边宽度 <outline color=red width=4>A label with outline</outline>
============================
Fontjs:
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
bmp_font: {
type: cc.Label,
default: null,
},
},
// use this for initialization
onLoad: function () {
this.bmp_font.string = "1111";
// 代码里面获取cc.Label组件, 修改文本内容
var sys_label = this.node.getChildByName("sys_label").getComponent(cc.Label);
sys_label.string = "MMM NNN";
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});