mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-12-11 07:09:28 +00:00
game runner
This commit is contained in:
34
assets/Scripts/AppRoot/AppRoot.ts
Normal file
34
assets/Scripts/AppRoot/AppRoot.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { _decorator, Component, Node, director, AudioSource } from "cc";
|
||||
import { SaveSystem } from "./SaveSystem";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("AppRoot")
|
||||
export class AppRoot extends Component {
|
||||
@property(AudioSource) private soundSource: AudioSource;
|
||||
@property(AudioSource) private musicSource: AudioSource;
|
||||
|
||||
private static instance: AppRoot;
|
||||
private saveSystem: SaveSystem;
|
||||
|
||||
public static get Instance(): AppRoot {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
public get SaveSystem(): SaveSystem {
|
||||
return this.saveSystem;
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
if (AppRoot.Instance == null) {
|
||||
AppRoot.instance = this;
|
||||
director.addPersistRootNode(this.node);
|
||||
this.init();
|
||||
} else {
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private init(): void {
|
||||
this.saveSystem = new SaveSystem();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user