cocos2d-js 控件——UITextAtlas

UITextAtlas(艺术字)公有属性、方法

/**
 * 构造函数
 */
TextAtlas();

/**
 * 创建一个TextAtlas对象
 * @return TextAtlas对象
 */
static TextAtlas* create();

/**
 * 从一个字符映射文件创建一个TextAtlas对象
 * @param stringValue  给定需要显示的字符串
 * 注意:输入的字符串必须是'.'、'/'、'1'、'2'、"3"、"4"、"5"、"6"、"7"、"8"、"9"
 * @param charMapFile  给定的字符映射文件名
 * 注意:文件图片中的文字必须在同一行,如果是两行的会无法显示完整
 * @param itemWidth    字符的宽度
 * @param itemHeight   字符的高度
 * @param startCharMap 字符映射文件的起始字符
 * 注意: 输入的字符串必须是'.'、'/'、'1'、'2'、"3"、"4"、"5"、"6"、"7"、"8"、"9"
 * @return TextAtlas对象
 */
static TextAtlas* create(const std::string& stringValue,
                         const std::string& charMapFile,
                         int itemWidth,
                         int itemHeight,
                         const std::string& startCharMap);

/** 
 * 从一个字符映射文件创建一个TextAtlas对象
 * @param stringValue  给定需要显示的字符串
 * 注意:输入的字符串必须是'.'、'/'、'1'、'2'、"3"、"4"、"5"、"6"、"7"、"8"、"9"
 * @param charMapFile  给定的字符映射文件名
 * 注意:文件图片中的文字必须在同一行,如果是两行的会无法显示完整
 * @param itemWidth    字符的宽度
 * @param itemHeight   字符的高度
 * @param startCharMap 字符映射文件的起始字符
 * 注意: 输入的字符串必须是'.'、'/'、'1'、'2'、"3"、"4"、"5"、"6"、"7"、"8"、"9"
 */
void setProperty(const std::string& stringValue,
                 const std::string& charMapFile,
                 int itemWidth,
                 int itemHeight,
                 const std::string& startCharMap);

/**
 * 为TextAtlas设置字符串值
 * @param value 给定需要显示的字符串
 */
void setString(const std::string& value);

/**
 * 获取TextAtlas的字符串值
 * @return 给定需要显示的字符串
 */
const std::string& getString() const;

/**
 * 获取字符串长度
 * 注意:这个长度将比原始字符串长度大
 * 如果你想得到原始字符串的长度,你应该调用this-> getString().size()来代替
 * @return  字符串长度
 */
ssize_t getStringLength()const;

UITextAtlas示例

// 此处字符"."对应的字符是"+",字符"./167"对应展示的即为"+-167"
var text = new ccui.TextAtlas("", "res/Fonts/HeadScoreFont_0.png", 15, 26, ".");
text.setString("./167");
text.setPosition(640, 360);
this.addChild(text);
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值