Skip to content

类: FloatingPanel

悬浮scene

继承

构造函数

构造函数

new FloatingPanel(): FloatingPanel

返回

FloatingPanel

继承自

Scene.constructor

属性

属性类型描述

currentChildCount

number

获取当前scene的子对象数量包括嵌套子对象

height

number

isSaveScene

boolean

用于标识scene是否为存档scene,如果是存档scene 在存档截图时会过滤掉isSaveScene为true的scene

mediator

any

Scene的容器类,包含了scene的所有内部数值事件处理和ui事件处理

示例

ts
this.setVar({....},this.mediator)

params

any

传入参数

示例

ts
const p1 = this.params[0]
cosnt p2 = this.params[1]

width

number

x

number

y

number

方法

addChild()

addChild<T>(target): void

添加子对象 悬浮scene的图片和按钮子对象 默认不会穿透

类型参数

T

T extends UIBaseView

参数

target

T

返回

void

重写了

Scene.addChild


awake()

awake(): void

声明周期函数 进入Scene的之后执行一次,执行顺序在init之前

返回

void

继承自

Scene.awake


beforeDestroy()

beforeDestroy(): void

当前scene即将销毁时执行一次

返回

void

继承自

Scene.beforeDestroy


close()

close(outData): void

关闭当前scene

参数

outData

any[]

传出参数

返回

void

示例

ts
this.close(["传出参数1","传出参数2"])

Warning

剧情呼叫的第一个scene关闭后会直接回到剧情,建议将剧情呼叫的第一个scene作为管理scene或者背景,在需要回到剧情时关闭

继承自

Scene.close


getConstData()

getConstData(): any

获取常量库数据 (这是引用传递 使用前请一定要进行深拷贝 否则会影响常量库原有值)

返回

any

示例

ts
let data = this.getConstData();

继承自

Scene.getConstData


getControlByAlias()

getControlByAlias(alias): UIBaseView

根据控件别名获取控件

参数

alias

string

返回

UIBaseView

示例

ts
let text = this.getControlByAlias('text1')

继承自

Scene.getControlByAlias


getValue()

getValue(path): any

获取数值

参数

path

string

数值

返回

any

示例

// 通过这种方式获取与其他系统交互的变量,在Scene环境中
cosnt i1 = this.getValue('this.int-1')

继承自

Scene.getValue


init()

init(): void

声明周期函数 进入Scene的之后执行一次,执行顺序在awake之后

返回

void

继承自

Scene.init


onRestore()

onRestore(data): void

存档还原时触发

参数

data

any

存档数据

返回

void

示例

ts
onRestore(data){
    this.test = data["test"]
}

继承自

Scene.onRestore


onSave()

onSave(): any

调用LM.save()时触发

返回

any

示例

ts
onSave(){
    return {
        "test":this.test
    }
}

继承自

Scene.onSave


onSceneClose()

onSceneClose(data): void

呼叫的scene被关闭时会调用此方法

参数

data

LMSceneCloseData

返回

void

示例

ts
onSceneClose(data:LMSceneCloseData){
 //id为data.id的scene关闭时会触发此方法
   console.log(data)
}

继承自

Scene.onSceneClose


preLoadRes()

preLoadRes(): string[]

设置预加载资源

返回

string[]

资源路径数组

继承自

Scene.preLoadRes


preLoadResFinish()

preLoadResFinish(): void

预加载资源完成之后执行一次,执行顺序在init之前

返回

void

继承自

Scene.preLoadResFinish


removeAllChild()

removeAllChild(): void

返回

void

已被弃用

自v1.3.0起废弃,请使用新的removeAllChildren 移除所有子对象 this.removeAllChild()

继承自

Scene.removeAllChild


removeAllChildren()

removeAllChildren(): void

返回

void

继承自

Scene.removeAllChildren


removeChild()

removeChild(child): void

移除子对象

参数

child

UIBaseView

返回

void

示例

ts
let text = new LM.TextView();
this.addChild(text)
this.removeChild(text)

继承自

Scene.removeChild


setSceneAnimation()

setSceneAnimation(styleIn, styleOut, time?): any

设置入场出场动画

参数

styleIn

SCENE_ANIMATION_STYLE

入场动画类型

styleOut

SCENE_ANIMATION_STYLE

出场动画类型

time?

number

动画时间 单位:毫秒 默认为300毫秒

返回

any

示例

ts
this.setSceneAnimation(SCENE_ANIMATION_STYLE.FADE_IN,SCENE_ANIMATION_STYLE.FADE_OUT1000)

继承自

Scene.setSceneAnimation


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]) 储存表数组的设置 (基于全局作用域)

继承自

Scene.setValue


showScene()

showScene(name, inData?): Promise<string>

添加一个scene

参数

name

string

scene名称

inData?

any[]

传入参数

返回

Promise<string>

示例

ts
LM.showScene('test',["传参1","传参2"])

继承自

Scene.showScene


update()

update(deltaTime?): void

循环更新函数 周期1帧一次

参数

deltaTime?

any

帧间隔时间,单位毫秒

返回

void

继承自

Scene.update