-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumberSelectionScreen.js
58 lines (43 loc) · 1.36 KB
/
numberSelectionScreen.js
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
function NumberSelectionScreen(hanoiSolvingScreen, max) {
var self = this;
var buttonsManager;
var incrementBtn;
var decrementBtn;
var okBtn;
var minusImg = new Image();
minusImg.src = "minus.png";
var plusImg = new Image();
plusImg.src = "plus.png";
var okImg = new Image();
okImg.src = "ok.png";
this.value;
this.init = function(defaultValue) {
this.value = defaultValue;
buttonsManager = new ButtonsManager();
decrementBtn = new ImageRectangleBtn(550, 100, 30, 30, minusImg, "", decrementValue);
incrementBtn = new ImageRectangleBtn(650, 100, 30, 30, plusImg, "", incrementValue);
okBtn = new ImageRectangleBtn(700, 100, 30, 30, okImg, "", confirmValue);
buttonsManager.add(decrementBtn);
buttonsManager.add(incrementBtn);
buttonsManager.add(okBtn);
}
function incrementValue() {
self.value = (max + self.value + 1) % max;
hanoiSolvingScreen.init(self.value);
}
function decrementValue() {
self.value = (max + self.value - 1) % max;
hanoiSolvingScreen.init(self.value);
}
function confirmValue(){
ScreensManager.switchToGameplayScreen(self.value);
}
this.update = function(){
buttonsManager.update();
}
this.draw = function(graphicsDevice) {
hanoiSolvingScreen.draw(graphicsDevice);
buttonsManager.draw(graphicsDevice);
graphicsDevice.fillText("" + this.value, 610, 120, 18, 'Arial', 'black');
}
}