mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
29 lines
767 B
TypeScript
29 lines
767 B
TypeScript
import { Vec2 } from "cc";
|
|
import GObject from "./base/GObject";
|
|
import { v3 } from "cc";
|
|
import { JNFrameInfo } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
|
|
|
|
|
export default class GBaseMode<T> extends GObject<T> {
|
|
|
|
//添加对象到场景中
|
|
addGObject(obj: GObject<{}>,pos?:Vec2){
|
|
obj.mode = this;
|
|
this.node.addChild(obj.node);
|
|
if(pos){
|
|
obj.node.setWorldPosition(v3(pos.x,pos.y,0));
|
|
}
|
|
}
|
|
|
|
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T) {
|
|
|
|
//重置 场景中的层级
|
|
[...this.node.children].sort((node1,node2) => node2.worldPosition.y - node1.worldPosition.y).forEach((node,index) => {
|
|
node.setSiblingIndex(index);
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|