69 lines
1.4 KiB
Plaintext
69 lines
1.4 KiB
Plaintext
// Engine 层 - Stage 场景类
|
|
// 继承自 Node 的场景类
|
|
|
|
Stage <- class(Node) {
|
|
// 构造函数
|
|
constructor() {
|
|
// 创建 C++ Scene 对象
|
|
this.C_Object = Scene.create();
|
|
}
|
|
|
|
// 设置背景颜色
|
|
function setBackgroundColor(r, g, b, a) {
|
|
if (this.C_Object) {
|
|
this.C_Object.setBackgroundColor(r, g, b, a);
|
|
}
|
|
}
|
|
|
|
// 获取背景颜色
|
|
function getBackgroundColor() {
|
|
if (this.C_Object) {
|
|
return this.C_Object.getBackgroundColor();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// 添加子节点
|
|
function addChild(node) {
|
|
if (this.C_Object && node && node.C_Object) {
|
|
this.C_Object.addChild(node.C_Object);
|
|
}
|
|
}
|
|
|
|
// 移除子节点
|
|
function removeChild(node) {
|
|
if (this.C_Object && node && node.C_Object) {
|
|
this.C_Object.removeChild(node.C_Object);
|
|
}
|
|
}
|
|
|
|
// 移除所有子节点
|
|
function removeAllChildren() {
|
|
if (this.C_Object) {
|
|
this.C_Object.removeAllChildren();
|
|
}
|
|
}
|
|
|
|
// 进入场景时调用
|
|
function onEnter() {
|
|
// 子类重写
|
|
}
|
|
|
|
// 退出场景时调用
|
|
function onExit() {
|
|
// 子类重写
|
|
}
|
|
|
|
// 每帧更新
|
|
function onUpdate(dt) {
|
|
// 子类重写
|
|
}
|
|
|
|
// 每帧渲染
|
|
function onRender() {
|
|
// 子类重写
|
|
}
|
|
};
|
|
|
|
print("Stage loaded");
|