-
Notifications
You must be signed in to change notification settings - Fork 1
/
Stage.ts
78 lines (63 loc) · 2.09 KB
/
Stage.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {IO} from "../Neu/BaseObjects/IO";
import {_} from "../main";
import DisplayObject = PIXI.DisplayObject;
import {O} from "../Neu/BaseObjects/O";
/**
* Created by MSI on 04.01.2017.
*/
export class Stage {
visible: boolean;
doProcess: boolean;
public currentFocus: number = null;
private focusable: Array<IO> = [];
private container: PIXI.Container = new PIXI.Container();
public layers: Object = {}; //MAP OF PIXI CONTAINERS
setFocusable(f: Array<IO>): void {
this.focusable = f;
}
addControllerHandlers(): void{
_.controls.onBtnPress = (btn) => {
if (this.currentFocus == null) {
this.currentFocus = 0
}
if (btn == 1 && this.currentFocus != null) {
this.focusable[this.currentFocus].click()
}
};
_.controls.onRight = () => {
if (this.currentFocus != null)
this.focusable[this.currentFocus].setFocus(false); else {
this.currentFocus = 0;
}
this.currentFocus = (this.currentFocus + 1) % this.focusable.length;
this.focusable[this.currentFocus].setFocus(true)
};
_.controls.onLeft = () => {
if (this.currentFocus != null)
this.focusable[this.currentFocus].setFocus(false); else {
this.currentFocus = 0;
}
this.currentFocus--;// = (this.currentFocus 1) % this.focusable.length
if (this.currentFocus < 0) this.currentFocus = this.focusable.length - 1;
this.focusable[this.currentFocus].setFocus(true);
}
}
process() {
};
onHide(newStage: Stage) {
_.sm.removeObjects();
_.sm.main.removeChild(this.container);
};
onShow() {
_.sm.main.addChild(this.container);
};
addLayer(name: string, l: any): any {
if (l) {
this.layers[name] = l;
} else {
this.layers[name] = new PIXI.Container();
}
this.container.addChild(this.layers[name]);
return this.layers[name];
}
}