-
Notifications
You must be signed in to change notification settings - Fork 3
/
MenuState.ts
46 lines (40 loc) · 1.27 KB
/
MenuState.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
/**
* Created by martelly on 4/13/2014.
*/
/// <reference path="interfaces.ts"/>
class MenuState extends TurbGameState
{
game:GameObject;
returnState:TurbGameState;
tileset:Tileset;
public static bgColor:number[] = [0, 0, 0.0, 1.0];
constructor(game:GameObject, jsonMap:String, returnState:TurbGameState = null)
{
super(game);
this.game.keyboard.resetListeners();
this.game = game;
this.returnState = returnState;
this.tileset = new Tileset(jsonMap+".json", game);
var viewport:number[] = [];
this.game.draw2D.getViewport(viewport);
}
update()
{
super.update();
this.game.graphicsDevice.clear(MenuState.bgColor, 1.0);
this.game.draw2D.begin(draw2D.blend.alpha, draw2D.sort.deferred);
if (this.game.keyboard.justPressed("P"))
{
this.game.nextState = this.returnState == null ? this.game.progression.getNextState() : this.returnState;
}
if (this.tileset.isLoaded())
{
if (!this.tileset.ranLoadMap) {
console.log("Loading menu tileset");
this.tileset.loadMap();
}
this.tileset.draw(this.game.draw2D, [0, 0]);
}
this.game.draw2D.end();
}
}