技术标签: cocos-creator CocosCreator
>>>>>
官方文档:RichText 组件参考 · Cocos Creator
富文本优缺点
优点:自定义颜色,大小,描边,还能加图片。对于复杂的文本表现力更好。
缺点:cocos的富文本是由Label组件拼装实现的。低版本会打断合批。Label太多导致卡顿。
此处仅测试几个常用标签:
// 换行符
<br/>
// 加粗
<b> </b>
// 字体颜色
<color=#FFFFFF> </color>
// 描边颜色及宽度
<outline color=#000000 width=2> </outline>
// 图片【需要在编辑器拉入所需图集】
<img src='"+图片名字 +"'/>
// 字体大小
<size=20>字体大小</size>
举例:
<color=#715f9a>请点击</c><color=#f53e00>下方按钮</c><color=#715f9a>兑换</c><color=#f53e00>金币</c>
组件理解:
max_width:0必须手动换行,否则指定宽度,自动换行。
line_height:行高
image_atlas:富文本要用到的图片的图集
富文本API摘抄自官方d.ts
/** !#en The RichText Component.
!#zh 富文本组件 */
export class RichText extends Component {
/** !#en Content string of RichText.
!#zh 富文本显示的文本内容。 */
string: string;
/** !#en Horizontal Alignment of each line in RichText.
!#zh 文本内容的水平对齐方式。 */
horizontalAlign: macro.TextAlignment;
/** !#en Font size of RichText.
!#zh 富文本字体大小。 */
fontSize: number;
/** !#en Custom System font of RichText
!#zh 富文本定制系统字体 */
fontFamily: string;
/** !#en Custom TTF font of RichText
!#zh 富文本定制字体 */
font: TTFFont;
/** !#en Whether use system font name or not.
!#zh 是否使用系统字体。 */
useSystemFont: boolean;
/** !#en The cache mode of label. This mode only supports system fonts.
!#zh 文本缓存模式, 该模式只支持系统字体。 */
cacheMode: Label.CacheMode;
/** !#en The maximize width of the RichText
!#zh 富文本的最大宽度 */
maxWidth: number;
/** !#en Line Height of RichText.
!#zh 富文本行高。 */
lineHeight: number;
/** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas.
!#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
imageAtlas: SpriteAtlas;
/** !#en
Once checked, the RichText will block all input events (mouse and touch) within
the bounding box of the node, preventing the input from penetrating into the underlying node.
!#zh
选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
handleTouchEvent: boolean;
}
整理不易,关注收藏不迷路。
目录:CocosCreator经典笔记_神兽白泽-程序员秘密
笔者qq、微信:1302109196
qq群:415468592
>>>>>
L2-007 家庭房产 (25 分)给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。输入格式:输入第一行给出一个正整数N(≤1000),随后N行,每行按下列格式给出一个人的房产:编号 父 母 k 孩子1 ... 孩子k 房产套数 总面积其中编号是每个人独有的一个4位数的...
名称glGetVertexAttrib - 返回通用顶点属性参数C规范void glGetVertexAttribfv( GLuint index, GLenum pname, GLfloat *params);void glGetVertexAttribiv( GLuint index, GLenum pname, GLint *...
微信小程序设置 background-img 报错微信小程序设置背景图片是会报错 提示必须使用网络资源或者 base64解决办法1 把图片转换为base64格式 (base64图片转换)把右边生成的base64编码放到url中就可以...
cardinality反应了series的维度,即不同的series的数量。序列基数是影响内存(RAM)使用量的主要因素。
序列密码加密代码:解密代码:输入一串字符串,利用产生的随机序列对字符串的每个字符逐个逐比特异或,产生的数,ASCII值变为对应的字符。加密代码:package com.jingfei.Encryptoin.com.jingfei.xulie;import java.math.BigInteger;import java.util.Scanner;public class XuLie...
一路跟踪源码,关键就是这两句:int QDialog::exec(){ Q_D(QDialog); if (d-&gt;eventLoop) { qWarning("QDialog::exec: Recursive call detected"); return -1; } bool deleteOnClose = tes...
高性能爬虫相关(IO多路复用,异步非阻塞)说到提高性能,我们可以想到的是利用多进程、多线程以及单线程实现并发,由于爬虫爬取信息时IO操作较多,所以利用单线程实现并发是较好的选择爬虫本质上还是建立socket连接,通过http请求获取数据本质: sk = socket() # 阻塞 sk.connect(('www.cnblogs.co...
文件后缀对应文件类型表 private static IDictionary<string, string> _mappings = new Dictionary<string, string> (StringComparer.InvariantCultureIgnore...
1. RedisTemplate快速开发 2. 两种实例的redis数据序列化区别 3. 用RedisTemplate还是StringRedisTemplate 4. 总结 1. RedisTemplate快速开发spring-redis对redis的五种数据类型是支持的。这个几个数据操作对象在demo的RedisConfig类中配置了,具体可前去查看代码。本文最重要的点是Object的序列化,下文会着重分析。 HashOperations:对hash类型的数..
vue开发百度地图很不兼容,如果直接循环添加事件会覆盖前面的事件,现采用网上说的一种闭包方式for(var i =0;i<_this.pointArray.length;i++){ var marker1 = new BMap.Marker(new BMap.Point(_this.pointArray[i].lng,_this.pointArray[i].lat)); marker1.setLabel(new BMap.
Android每新建一个项目,都会有两个build.gradle文件,有一个在最外层目录下,有一个在app目录下,如果切换到 Android 模式下则全部在 Gradle Scripts下。下面先介绍看起来少的(最外层目录下的)。主要介绍:jcenter():一个代码仓库,许多的Android开源项目都会将代码托管到jcenter上。作用:配置后,可以在项目中轻松使用任何的jcenter上...
Jsp一共包含三个编译指令和七个动作指令。三个编译指令为:page、include、taglib。七个动作指令为:jsp:forward、jsp:param、jsp:include、jsp:plugin、jsp:useBean、jsp:setProperty、jsp:getProperty。...