FGUI日常使用
一.列表動態(tài)邊緣留空
const newMargin = new fgui.Margin();const margin = this.ui.m_List.margin;//將列表的邊緣留空數(shù)據(jù)記錄到新的Margin上newMargin.top = margin.top;newMargin.bottom = margin.bottom;newMargin.left = margin.left;newMargin.right = margin.right;//其它地方調(diào)用newMargin.left = 1;//設(shè)置左邊緣留空為1this.ui.m_List.margin = newMargin;//刷新列表邊緣留空二.關(guān)聯(lián)縮放
背景:fgui編輯器不支持關(guān)聯(lián)縮放,按鈕效果單獨放在最頂層(drawCall)按鈕支持縮放,按鈕效果spine,跟隨縮放的情況
思路:使用自定義函數(shù)覆蓋了原有的setScale函數(shù)(野路子,有更好方案留言改進)
三.使用外部資源
1.spine
//使用spine數(shù)據(jù)默認值const skeleton = skeletonData.skeletonJson.skeleton;const spW = Math.floor(skeleton.width);//包圍盒wconst spH = Math.floor(skeleton.height);//包圍盒hconst aX = Math.floor(skeleton.width + skeleton.x);//錨點xconst aY = Math.floor(skeleton.height + skeleton.y);//錨點y//同步編輯器spine設(shè)置大小和錨點const paintSpItem = this.paintItem.m_PaintSp;paintSpItem.setSize(spW, spH);paintSpItem.setSpine(skeletonData, new cc.Vec2(aX, aY), true);2.圖片
const spriteFrame = <cc.SpriteFrame>resInfo.res;const paintItem = this.paintItem.m_Paint;const texture = spriteFrame.getTexture();paintItem.setSize(texture.width, texture.height);paintItem.texture = spriteFrame;四.進度條動畫
背景:進度條動畫在許多動畫之間,需要知道進度條動畫完成的時機,還需要動畫加快效果
const gTweener = pro.tweenValue(90, 1);//進度條有動態(tài)的過程gTweener.setTimeScale(3);//修改進度條動畫播放速度gTweener.onComplete(() => {//進度條動畫完成回調(diào)})五.遇到的坑
1.fgui源碼未處理階乘問題,導(dǎo)致編輯器效果和游戲內(nèi)不一致
2.編輯器里加載的spine,界面構(gòu)造的時候,content最開始會沒值(沒有加載完,如果開始就對content操作要自行判斷)
總結(jié)
- 上一篇: Android Studio开发环境搭建
- 下一篇: addEventListener 的事件