LuaQuick框架(客户端)

996传奇引擎三端lua快速开发


容器(Layout)

<p>[TOC]</p> <h2>层</h2> <h3>创建层容器</h3> <pre><code>co.Layout:create(parent, id, x, y, width, height, isClip)</code></pre> <pre><code>parent  父节点对象 id      唯一ID x       位置 横坐标 y       位置 纵坐标 width   宽度 height  长度 isClip  是否裁切</code></pre> <h3>设置层背景颜色</h3> <pre><code>co.Layout:setBackGroundColor(widget, color)</code></pre> <pre><code>widget 基础容器对象 color  色值(#000000) 渐变色需传参table{&amp;quot;#FF0000&amp;quot;,&amp;quot;#FFFFFF&amp;quot;}</code></pre> <h3>设置层背景颜色类型</h3> <pre><code>co.Layout:setBackGroundColorType(widget,type)</code></pre> <pre><code>widget 基础容器对象 type   类型 [1.单色; 2.渐变色]</code></pre> <h3>设置层背景颜色不透明度</h3> <pre><code>co.Layout:setBackGroundColorOpacity(widget,value)</code></pre> <pre><code>widget 基础容器对象 value  不透明度(0-255)</code></pre> <h3>设置层背景是否裁切</h3> <pre><code>co.Layout:setClippingEnabled(widget, bool)</code></pre> <pre><code>widget 基础容器对象 bool   是否裁切</code></pre> <h3>设置层背景图片</h3> <pre><code>co.Layout:setBackGroundImage(widget, filename)</code></pre> <pre><code>widget   基础容器对象 filename 图片路径</code></pre> <h3>设置层背景图片九宫格</h3> <pre><code>co.Layout:setBackGroundImageScale9Slice(widget, scale9l, scale9r, scale9t, scale9b)</code></pre> <pre><code>widget   基础容器对象 scale9l 左边比例 scale9r 右边比例 scale9t 上边比例 scale9b 下边比例</code></pre> <h3>移除层背景图片设置 [3.40.5版本]</h3> <pre><code>co.Layout:removeBackGroundImage(widget)</code></pre> <h3>获取层背景图片文件路径[3.40.8版本]</h3> <pre><code>co.Layout:getBackGroundImage(widget)</code></pre> <h3>自适应布局 返回值: table尺寸</h3> <pre><code>co.Layout:updateLayout(widget, param)</code></pre> <pre><code>widget 组件对象 param = { dir: 1:垂直; 2: 水平; 3: 两者 gap:  x: 左右间距; y: 上下间距; l: 左边距; t: 上边距 addDir: 动画增长方式 1: 从上到下(从左到右)(多行从左上角), 2:中间到两边(多行从右上角), 3:从下到上(从右到左) colnum: 多行列数(dir必须是3) autosize: 根据内容自适应容器 sortfunc: 排序函数 interval:增长方式动画播放时间间隔, 不传值则不播放动画 rownums : 每一行的数量table ; 例如:rownums = {3, 2} (第一行3个元素,第二行2个元素) }</code></pre> <h2>容器通用</h2> <h3>创建容器数据,容器中需要一个子项目作为蓝图</h3> <pre><code>co.Layout:reloadData(widget,len,callback)</code></pre> <pre><code>widget   容器对象 len      数据长度 callback 回调函数,参数(子项目)</code></pre> <h3>更新所有项目</h3> <pre><code>co.Layout:updateItems(widget)</code></pre> <h3>通过子控件对象更新控件信息</h3> <pre><code>co.Layout:updateItemByWidget(layout,widget)</code></pre> <pre><code>layout   容器对象 widget   子节点对象</code></pre> <h3>通过子节点标记更新某个子项目</h3> <pre><code>co.Layout:updateItemByTag(layout,tag)</code></pre> <pre><code>layout   容器对象 tag      子节点标记</code></pre> <h3>通过子节点名称更新某个子项目</h3> <pre><code>co.Layout:updateItemByName(layout,name)</code></pre> <pre><code>layout   容器对象 name     子节点名称</code></pre> <h3>获取容器方向,暂时调用cocos原生接口,等待GUI更新</h3> <pre><code>co.Layout:getDirection(widget)</code></pre> <h2>属性容器</h2> <h3>创建属性容器</h3> <pre><code>co.Layout:createAttrView(layout,t)</code></pre> <pre><code>layout 基础容器对象 参数可以是属性字符串,装备id,装备位,唯一id,属性table数据 具体参数,参考setDefaultValue方法 --创建属性视图 ---* layout 基础容器对象 ---* 参数可以是属性字符串,装备id,装备位,唯一id,属性table数据 ---* 具体参数,参考setDefaultValue方法 t = { style      = t.style or 1      -- 展示风格:用于不同展示的样式,默认风格1 stace      = t.stace or 1      -- 文本间距:属性名称%s占位空隙 flag       = t.flag            -- 标记:true显示,nil or false隐藏 font       = t.font or 16      -- 字体大小,默认16 c3b1       = t.c3b1            -- 名称颜色 c3b2       = t.c3b2            -- 属性颜色 margin     = t.margin or 0     -- 属性间距:调整属性间距,默认0 vDis       = t.vDis or 2       -- 垂直展示:1(上对齐),2(居中),3(下对齐),默认剧中 hDis       = t.hDis or 2       -- 水平展示:1(左对齐),2(居中),3(右对齐),默认剧中 tyte       = t.tyte or 1       -- 1(最大高度为父节点高度),2(跟随内容自适应高度),默认为父节点高度 isColor    = t.isColor         -- 属性名颜色是否同步属性值颜色 showStyle  = t.showStyle or 1  -- 显示风格:1.正常数值,2.亿万数值 isClitting = t.isClitting      -- 是否裁剪,true裁剪 p.ShowType   = t.ShowType or 1   --默认1时 攻击显示上下限 为2时上下限有0时只显示一个值 extra      = t.extra or {{text,color=&amp;quot;#FFFFFF&amp;quot;}}     -- 根据表格文本显示额外添加字符串 extra2     = t.extra2      --后面继续显示没有名字的属性值{OffSetX偏移坐标,str,itemId,tos,makeId,data,equitData,attrId,attrTyte,FrontImg={res,x,y}} FrontImg属性与下级属性之间增加图片和xy偏移坐标 str       = t.str         -- 创建方式1:通过字符串创建属性视图 itemId    = t.itemId      -- 创建方式1:通过装备id创建属性视图 tos       = t.tos         -- 创建方式2:通过装备位置创建属性视图 makeId    = t.makeId      -- 创建方式3:通过装备唯一id创建属性视图 data      = t.data        -- 创建方式4:通过属性table数据创建属性视图 equitData = t.equitData   -- 创建方式5:通过装备数据创建属性视图 attrId    = t.attrId      -- 创建方式6:通过属性ID创建属性视图,关联cfg_ManageAttr表的ID attrTyte = t.attrTyte     -- 配合通过itemId,tos,makeId创建属性视图,0创建基础属性,1创建自定义属性1,2创建自定义属性2,3创建自定义属性3,4创建自定义属性4,5创建自定义属性5,10创建自定义属性1-5 }</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=2a18158fb9c16ead325d96e3f1fe63b6&amp;amp;file=file.png" alt="" /> <img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=3b8d94cbadd5bc73a56f51466214f8a9&amp;amp;file=file.png" alt="" /></p> <h3>设置属性颜色</h3> <pre><code>co.Layout:setAttrColor(layout,c3b)</code></pre> <h3>设置属性名称颜色</h3> <pre><code>co.Layout:setAttrNameColor(layout,c3b)</code></pre> <h3>设置属性值颜色</h3> <pre><code>co.Layout:setAttrValueColor(layout,c3b)</code></pre> <h3>设置属性位置</h3> <pre><code>co.Layout:setAttrPosition(layout,x,y)</code></pre> <h3>获取属性容器位置</h3> <pre><code>co.Layout:getAttrPosition(layout)</code></pre> <h3>获取属性容器大小</h3> <pre><code>co.Layout:getAttrContentSize(layout)</code></pre> <h3>获取属性内部容器(ListView)</h3> <pre><code>co.Layout:getAttrInnerContainer(layout)</code></pre> <h3>获取属性内部容器ListView大小</h3> <pre><code>co.Layout:getAttrInnerContainerSize(layout)</code></pre> <h2>消耗容器</h2> <h3>创建消耗容器</h3> <pre><code>co.Layout:createConsumeView(layout,t,style)</code></pre> <pre><code>layout 基础容器对象 t      参考 style  消耗视图风格 (1,2,3,4) --创建消耗视图 layout 基础容器对象 t 参考 style 消耗视图风格1-4 layout 基础容器对象 参数可以是属性字符串,装备id,装备位,唯一id,属性table数据 具体参数,参考setDefaultValue方法 t = { font = t.font or 18 -- 字体大小:默认18 c3b = t.c3b -- 数值文本颜色,co.c3b margin = t.margin or 8 -- 项目间距:默认8 style == 4 默认=1 pos = t.pos or 2 -- 对齐方式:1.左对齐; 2.居中对齐; 3.右对齐; scale = t.scale or 0.7 -- icon缩放比例,默认0.7 iconx = t.iconx or 0 -- icon偏移值x icony = t.icony or 0 -- icon偏移值y data = t.data -- 需要消耗物品数据 showStyle = t.showStyle or 1 -- 显示风格:1.正常数值,2.亿万数值 isCount = t.isCount -- true显示配置表数量,不显示当前数量 isCurNum = t.isCurNum -- true只显示当前拥有数量 bageff = t.bageff -- 只显示内观特效不显示背包特效 textPos = t.textPos or 1 -- 对消耗视图风格2有效,1文本数值显示框的右下角,2显示框外下方居中 hideNum = t.hideNum -- true隐藏道具数量 double = t.double or 1 -- 显示道具数量倍数 animId = t.animId -- 对带有物品框的消耗风格增加额外的特效,可以是一个特效ID,可以是一个特效ID数组 checkPos = t.checkPos -- 是否检测对应装备位穿戴的装备 cellSize = t.cellSize -- 设置物品框大小,{宽度,高度} title = t.title or &amp;quot;消耗:&amp;quot; -- style ~= 3 title or &amp;quot;消耗:&amp;quot; 显示标题:默认(消耗:),空字符串可隐藏消耗 look = true --默认true }</code></pre> <h3>创建消耗容器样式1</h3> <pre><code>co.Layout:createConsumeViewByStyle1(layout,param)</code></pre> <h3>创建消耗容器样式2</h3> <pre><code>co.Layout:createConsumeViewByStyle2(layout,param)</code></pre> <h3>创建消耗容器样式3</h3> <pre><code>co.Layout:createConsumeViewByStyle3(layout,param)</code></pre> <h3>创建消耗容器样式4</h3> <pre><code>co.Layout:createConsumeViewByStyle4(layout,param)</code></pre> <h3>设置消耗容器位置</h3> <pre><code>co.Layout:setConsumePosition(layout,value)</code></pre> <pre><code>value 为number时 value = 1     co.Widget:setAnchorPoint(widget,co.p(0,0.5))     co.Widget:setPosition(widget,co.p(0.1,size.height/2)) value = 2     co.Widget:setAnchorPoint(widget,co.p(0.5,0.5))     co.Widget:setPosition(widget,co.p(size.width/2+2,size.height/2)) value = 3     co.Widget:setAnchorPoint(widget,co.p(1,0.5))     co.Widget:setPosition(widget,co.p(size.width,size.height/2)) value 为table时,co.Widget:setPosition(widget,value)</code></pre> <h3>获取消耗容器位置</h3> <pre><code>co.Layout:getConsumePosition(layout)</code></pre> <h3>设置消耗容器字体颜色</h3> <pre><code>co.Layout:setConsumeFontColor(layout,c3b)</code></pre> <h3>更新消耗容器大小</h3> <pre><code>co.Layout:updateConsumeContentSize(layout)</code></pre> <h3>更新消耗容器</h3> <pre><code>co.Layout:updateConsumeCount(layout)</code></pre> <h3>以List的方式加载翻页容器</h3> <pre><code>co.Layout:reloadListPageView(layout,len,func)</code></pre> <h3>以Table的方式加载翻页容器</h3> <pre><code>co.Layout:reloadTablePageView(layout,len,func)</code></pre> <h3>获取所有项目(只有当前页面的项目)</h3> <pre><code>co.Layout:getItems(layout)</code></pre> <h3>设置PageView配置参数</h3> <pre><code>co.Layout:setPageView(layout,count,itemCount,dir,column,horizontal,vertical)</code></pre> <pre><code>count            --页数 itemCount        --每页展示项目数量 dir              --翻页方向 1水平翻页,2垂直翻页 column           --ListView行数 或 TableView列数 horizontal or 2  --ListView间距 或 TableView水平间距 vertical or 2    --TableView垂直间距</code></pre> <h3>跳到某页</h3> <pre><code>co.Layout:jumpPage(layout,page,style)</code></pre> <h3>跳到下页</h3> <pre><code>co.Layout:jumpNextPage(layout,style)</code></pre> <h3>返回上页</h3> <pre><code>co.Layout:jumpBackPage(layout,style)</code></pre> <h3>获取当前是第几页</h3> <pre><code>co.Layout:getCurPage(layout)</code></pre> <h3>获取总页数</h3> <pre><code>co.Layout:getCountPage(layout)</code></pre> <h3>通过标记更新翻页容器子项目</h3> <pre><code>co.Layout:updatePageViewItemByTag(layout,tag)</code></pre> <h3>通过项目名称更新翻页容器子项目</h3> <pre><code>co.Layout:updatePageViewItemByName(layout,name)</code></pre>

页面列表

ITEM_HTML