Appearance
类: FloatingPanel
悬浮scene
继承
构造函数
构造函数
new FloatingPanel():
FloatingPanel
返回
FloatingPanel
继承自
属性
| 属性 | 类型 | 描述 |
|---|---|---|
| 获取当前scene的子对象数量包括嵌套子对象 | |
| ‐ | |
| 用于标识scene是否为存档scene,如果是存档scene 在存档截图时会过滤掉isSaveScene为true的scene | |
| Scene的容器类,包含了scene的所有内部数值事件处理和ui事件处理 示例 ts | |
| 传入参数 示例 ts | |
| ‐ | |
| ‐ | |
| ‐ |
方法
addChild()
addChild<
T>(target):void
添加子对象 悬浮scene的图片和按钮子对象 默认不会穿透
类型参数
T
T extends UIBaseView
参数
target
T
返回
void
重写了
awake()
awake():
void
声明周期函数 进入Scene的之后执行一次,执行顺序在init之前
返回
void
继承自
beforeDestroy()
beforeDestroy():
void
当前scene即将销毁时执行一次
返回
void
继承自
close()
close(
outData):void
关闭当前scene
参数
outData
any[]
传出参数
返回
void
示例
ts
this.close(["传出参数1","传出参数2"])Warning
剧情呼叫的第一个scene关闭后会直接回到剧情,建议将剧情呼叫的第一个scene作为管理scene或者背景,在需要回到剧情时关闭
继承自
getConstData()
getConstData():
any
获取常量库数据 (这是引用传递 使用前请一定要进行深拷贝 否则会影响常量库原有值)
返回
any
示例
ts
let data = this.getConstData();继承自
getControlByAlias()
getControlByAlias(
alias):UIBaseView
根据控件别名获取控件
参数
alias
string
返回
示例
ts
let text = this.getControlByAlias('text1')继承自
getValue()
getValue(
path):any
获取数值
参数
path
string
数值
返回
any
示例
// 通过这种方式获取与其他系统交互的变量,在Scene环境中
cosnt i1 = this.getValue('this.int-1')继承自
init()
init():
void
声明周期函数 进入Scene的之后执行一次,执行顺序在awake之后
返回
void
继承自
onRestore()
onRestore(
data):void
存档还原时触发
参数
data
any
存档数据
返回
void
示例
ts
onRestore(data){
this.test = data["test"]
}继承自
onSave()
onSave():
any
调用LM.save()时触发
返回
any
示例
ts
onSave(){
return {
"test":this.test
}
}继承自
onSceneClose()
onSceneClose(
data):void
呼叫的scene被关闭时会调用此方法
参数
data
返回
void
示例
ts
onSceneClose(data:LMSceneCloseData){
//id为data.id的scene关闭时会触发此方法
console.log(data)
}继承自
preLoadRes()
preLoadRes():
string[]
设置预加载资源
返回
string[]
资源路径数组
继承自
preLoadResFinish()
preLoadResFinish():
void
预加载资源完成之后执行一次,执行顺序在init之前
返回
void
继承自
removeAllChild()
removeAllChild():
void
返回
void
已被弃用
自v1.3.0起废弃,请使用新的removeAllChildren 移除所有子对象 this.removeAllChild()
继承自
removeAllChildren()
removeAllChildren():
void
返回
void
继承自
removeChild()
removeChild(
child):void
移除子对象
参数
child
返回
void
示例
ts
let text = new LM.TextView();
this.addChild(text)
this.removeChild(text)继承自
setSceneAnimation()
setSceneAnimation(
styleIn,styleOut,time?):any
设置入场出场动画
参数
styleIn
入场动画类型
styleOut
出场动画类型
time?
number
动画时间 单位:毫秒 默认为300毫秒
返回
any
示例
ts
this.setSceneAnimation(SCENE_ANIMATION_STYLE.FADE_IN,SCENE_ANIMATION_STYLE.FADE_OUT,1000)继承自
setValue()
setValue(
path,data):any
设置数值
参数
path
string
数值
data
any
数据
返回
any
示例
// 通过这种方式设置其他系统交互的变量
this.setValue('this.int-1',9) 临时数值的设置(基于scene或者橱窗本身作用域)
this.setValue('root.int-1',9) 全局数值的设置 (基于全局作用域)
this.setValue('root.plus_int-1',9) 全局二周目数值的设置 (基于全局作用域)
this.setValue('root.plus_list-1',[1,1]) 全局二周目数组的设置 (基于全局作用域)
this.setValue('this.savelist-1',[9]) 储存表数组的设置 (基于全局作用域)继承自
showScene()
showScene(
name,inData?):Promise<string>
添加一个scene
参数
name
string
scene名称
inData?
any[]
传入参数
返回
Promise<string>
示例
ts
LM.showScene('test',["传参1","传参2"])继承自
update()
update(
deltaTime?):void
循环更新函数 周期1帧一次
参数
deltaTime?
any
帧间隔时间,单位毫秒
返回
void