[LayaAirIDE3]场景中运行时脚本 无法继承自Laya.Script只能自己创建调用帧循环吗?
//目前能实现的仅是这样实现帧循环
const { regClass } = Laya;
import { 测试Base } from "./测试.generated";
@regClass()
export class 测试 extends 测试Base {
onAwake(): void {
Laya.stage.frameLoop(1, this, this.onUpdate);
}
onUpdate(): void {
console.log("dddd");
}
onDestroy(): void {
Laya.stage.clearTimer(this, this.onUpdate);
}
}
要回复问题请先登录
1 个回复
LayaAir大为
赞同来自:
import { RuntimeScript } from "./RuntimeScript";
const { regClass, property } = Laya;
@regClass()
export class NewScript extends Laya.Script {
private ui : RuntimeScript;
onStart() {
// 获得场景的Runtime对象
this.ui = this.owner.scene as RuntimeScript;
// Button添加鼠标事件,让Image不显示
this.ui.Button.on( Laya.Event.MOUSE_DOWN, null, ()=>{
this.ui.Image.visible = false;
});
}
}