日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

FGUI日常使用

發(fā)布時間:2023/12/9 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 FGUI日常使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一.列表動態(tài)邊緣留空

const newMargin = new fgui.Margin();const margin = this.ui.m_List.margin;//將列表的邊緣留空數據記錄到新的Margin上newMargin.top = margin.top;newMargin.bottom = margin.bottom;newMargin.left = margin.left;newMargin.right = margin.right;//其它地方調用newMargin.left = 1;//設置左邊緣留空為1this.ui.m_List.margin = newMargin;//刷新列表邊緣留空

二.關聯(lián)縮放

背景:fgui編輯器不支持關聯(lián)縮放,按鈕效果單獨放在最頂層(drawCall)按鈕支持縮放,按鈕效果spine,跟隨縮放的情況
思路:使用自定義函數覆蓋了原有的setScale函數(野路子,有更好方案留言改進)

private relationScale(btn: fgui.GButton, relationsItemArray: fgui.GComponent[]): void {const sourceSetScale = btn.setScale;btn.setScale = (sx: number, sy: number) => {sourceSetScale.call(btn, sx, sy);//修改this指向relationsItemArray.forEach((item: fgui.GComponent) => {item.setScale(sx, sy);});}}

三.使用外部資源

1.spine

//使用spine數據默認值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設置大小和錨點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(() => {//進度條動畫完成回調})

五.遇到的坑

1.fgui源碼未處理階乘問題,導致編輯器效果和游戲內不一致

2.編輯器里加載的spine,界面構造的時候,content最開始會沒值(沒有加載完,如果開始就對content操作要自行判斷)

總結

以上是生活随笔為你收集整理的FGUI日常使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。