shadow-function
Version:
ioing lib - shadow Function, worker Function
99 lines (87 loc) • 3.45 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p] }
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () { this.constructor = d }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __())
}
})()
var test = ui.test.TestPageUI
var Label = Laya.Label
var Handler = Laya.Handler
var Loader = Laya.Loader
var WebGL = Laya.WebGL
var TestUI = /** @class */ (function (_super) {
__extends(TestUI, _super)
function TestUI () {
var _this = _super.call(this) || this
//btn是编辑器界面设定的,代码里面能直接使用,并且有代码提示
_this.btn.on(Laya.Event.CLICK, _this, _this.onBtnClick)
_this.btn2.on(Laya.Event.CLICK, _this, _this.onBtn2Click)
return _this
}
TestUI.prototype.onBtnClick = function () {
//手动控制组件属性
this.radio.selectedIndex = 1
this.clip.index = 8
this.tab.selectedIndex = 2
this.combobox.selectedIndex = 0
this.check.selected = true
}
TestUI.prototype.onBtn2Click = function () {
//通过赋值可以简单快速修改组件属性
//赋值有两种方式:
//简单赋值,比如:progress:0.2,就是更改progress组件的value为2
//复杂复制,可以通知某个属性,比如:label:{color:"#ff0000",text:"Hello LayaAir"}
this.box.dataSource = { slider: 50, scroll: 80, progress: 0.2, input: 'This is a input', label: { color: '#ff0000', text: 'Hello LayaAir' } }
//list赋值,先获得一个数据源数组
var arr = []
for (var i = 0; i < 100; i++) {
arr.push({ label: 'item ' + i, clip: i % 9 })
}
//给list赋值更改list的显示
this.list.array = arr
//还可以自定义list渲染方式,可以打开下面注释看一下效果
//list.renderHandler = new Handler(this, onListRender);
}
TestUI.prototype.onListRender = function (item, index) {
//自定义list的渲染方式
var label = item.getChildByName('label')
if (index % 2) {
label.color = '#ff0000'
} else {
label.color = '#000000'
}
}
return TestUI
}(ui.test.TestPageUI))
//程序入口
Laya.init(600, 400, WebGL)
//激活资源版本控制
console.log('L67:Laya.ResourceVersion.FILENAME_VERSION=', Laya.ResourceVersion.FILENAME_VERSION)
console.log('Laya.ResourceVersion.manifest=', Laya.ResourceVersion.manifest)
console.log('laya.net.ResourceVersion=', laya.net.ResourceVersion.type)
// 1。 原本加载 version 的方式
// Laya.ResourceVersion.enable('version.json', Handler.create(null, beginLoad), Laya.ResourceVersion.FILENAME_VERSION)
// 2。 直接实现方式
laya.net.ResourceVersion.type = Laya.ResourceVersion.FILENAME_VERSION
Laya.ResourceVersion.manifest = {}
beginLoad()
function beginLoad () {
console.log('L787:Laya.loader:start')
console.log('L786:Laya.loader._resMap=', Laya.loader._resMap)
Laya.loader.load('res/atlas/comp.atlas', Handler.create(null, onLoaded))
// onLoaded()
}
function onLoaded () {
console.log('L792:Laya.loader._resMap=', Laya.loader._resMap)
//实例UI界面
var testUI = new TestUI()
Laya.stage.addChild(testUI)
}
//# sourceMappingURL=LayaUISample.js.map