Lua封装增加CCLabel接口
2015-11-29 17:31
453 查看
添加CCLabel接口,支持Tag替换
font参数类型如下:
EX:
function AddLabel( str, pos, target, tag, font, anchor, stroked, fz ) if( font == nil ) then font = G_Font_White end if( anchor == nil ) then anchor = ccp( 0.5, 0.5 ); end if( tag == nil ) then tag = 0; end if( tag ~= 0 and target:getChildByTag(tag) ) then target:removeChildByTag( tag, true ); end local s, e = string.find(font.name, ".fnt") local label local fontSize = fz if fontSize == nil then fontSize = font.size end if s then label = CCLabelBMFont:create( str, font.name ) label:setScale(fontSize) else label = CCLabelTTF:create( str, font.name, fontSize ) if stroked or font.stroked then AddStrokeOnLabel( label ) end end label:setPosition( pos ) label:setAnchorPoint( anchor ) label:setColor( font.color ) target:addChild( label, 0, tag ) return label; end
font参数类型如下:
G_Font_YellowStroke_Small = { name = "DFPYuanW7-GB.ttf", size = 12, color = ccc3(251,224,114), stroked = true }
EX:
AddLabel( "文字", ccp(10,12), father, 0, G_Font_YellowStroke_Small, ccp(0.5, 0.5))
相关文章推荐
- 详解Lua中的表的概念及其相关操作方法
- Lua编程示例(二):面向对象、metatable对表进行扩展
- 把Lua编译进nginx步骤方法
- Lua脚本自动生成APK包
- Lua中的元表(metatable)、元方法(metamethod)详解
- Lua中的metatable介绍
- Lua中ipair和pair的区别
- Lua中的函数精讲笔记
- 浅谈Lua的面向对象特性
- 详解Lua中的变量相关知识点
- Lua脚本语言入门笔记
- Lua脚本调用外部脚本
- 详解Lua中的if语句的使用方法
- Lua中调用函数使用点号和冒号的区别
- Lua中的闭合函数、非全局函数与函数的尾调用详解
- Lua中强大的元方法__index详解
- Lua中调用C++函数示例
- Lua面向对象之类和继承浅析
- Lua性能优化技巧(一):前言
- Lua中获取table长度问题探讨