用 game就是这样,但是game的on方法被重写了,回调签名是()=>void,不过实际上一样能拿到参数,game换成director一样的,但是这样做好不好我就不知道了
@ccclass('Parent')
export class Parent extends Component {
protected onLoad(): void {
//@ts-ignore
game.on("MyEvent",(arg)=>{
console.log("收到MyEvent事件:" + arg);
}, this);
}
start() {
game.emit("MyEvent", "事件参数")
}
protected onDestroy(): void {
game.targetOff(this);
}
}
![]()


