生活随笔
收集整理的這篇文章主要介紹了
laya ts fgui的list滚动列表设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先建項目,創建標簽,創建item
最后在main里面找到創建的list進行設置資源
代碼設置如下
import Itemtest
from "./Itemtest";
import Item
from "./Itemtest";export default class fgu extends Laya.Script
{private _view
:fgui
.GComponent
;private _vbn1
:fgui
.GProgressBar
;private _btn2
:fgui
.GComponent
;private _list
:fgui
.GList
;constructor() { super();fgui
.UIPackage
.loadPackage("res/UI/FguiTest",Laya
.Handler
.create(this,this.onUILoad
)); }onUILoad(){this._view
= fgui
.UIPackage
.createObject("FguiTest", "Main").asCom
;this._view
.makeFullScreen();fgui
.GRoot
.inst
.addChild(this._view
);var _bnt
:fgui
.GButton
=this._view
.getChild("n2").asButton
;_bnt
.selectedIcon_bnt
.onClick(this,()=>{this._view
.getChild("n2").asButton
.x
+=Math
.round(Math
.random()*(300));this._view
.getChild("n2").asButton
.y
+=Math
.round(Math
.random()*(300))console.log( this._view
.getChild("n5").asProgress
.value
);this._view
.getChild("n5").asProgress
.value
+=2;});fgui
.UIObjectFactory
.setExtension("res/UI/FguiTest/Item",Itemtest
);this._list
=this._view
.getChild("list").asList
;for (let index
= 0; index
<10; index
++) {<Itemtest
>this._list
.addItemFromPool();}this._list
.ensureBoundsCorrect();for (let index
= 0; index
< 10; index
++) {<Itemtest
>this._list
.getChildAt(index
); }console.log("list名字"+this._list
.name
);var _GSlider
:fgui
.GSlider
=this._view
.getChild("n6").asSlider
;_GSlider
.stopDrag();Laya
.stage
.frameLoop(3,this,this.loopr
,[_GSlider
]);}loopr(cell
:any):void{console.log(cell
.value
);}onEnable(): void {}onUpdate(): void {}onDisable(): void {}
}
總結
以上是生活随笔為你收集整理的laya ts fgui的list滚动列表设置的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。