-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.ts
54 lines (45 loc) · 2.02 KB
/
Game.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { Context, IContext, MVCSBundle } from "@robotlegsjs/core";
import { PhaserBundle } from "../src/robotlegs/bender/bundles/phaser/PhaserBundle";
import { ContextStateManager } from "../src/robotlegs/bender/extensions/contextStateManager/impl/ContextStateManager";
import { StateKey } from "./constants/StateKey";
import { Boot } from "./states/Boot";
import { Preload } from "./states/Preload";
import { GameTitle } from "./states/GameTitle";
import { Main } from "./states/Main";
import { GameOver } from "./states/GameOver";
import { GameConfig } from "./config/GameConfig";
import { StateMediatorConfig } from "./config/StateMediatorConfig";
export class Game extends Phaser.Game {
private _context: IContext;
constructor(
width?: number | string,
height?: number | string,
renderer?: number,
parent?: any,
state?: any,
transparent?: boolean,
antialias?: boolean,
physicsConfig?: any
) {
super(width, height, renderer, parent, state, transparent, antialias, physicsConfig);
this._context = new Context();
this._context
.install(MVCSBundle, PhaserBundle)
.configure(new ContextStateManager(this.state))
.configure(StateMediatorConfig)
.configure(GameConfig)
.initialize();
this.state.add(StateKey.BOOT, Boot, false);
this.state.add(StateKey.PRELOAD, Preload, false);
this.state.add(StateKey.GAME_TITLE, GameTitle, false);
this.state.add(StateKey.MAIN, Main, false);
this.state.add(StateKey.GAME_OVER, GameOver, false);
this.state.start(StateKey.BOOT);
}
}