-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpController.ts
More file actions
69 lines (63 loc) · 1.59 KB
/
Copy pathHelpController.ts
File metadata and controls
69 lines (63 loc) · 1.59 KB
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
/// <reference path="GameLoop.ts" />
module Game{
export class HelpController{
gameloop;
canvas;
width;
height;
model;
helpView;
gameMode;
constructor(gameloop,canvas,width,height,model,helpView, gameMode){
this.gameloop = gameloop;
this.canvas = canvas;
this.model = model
this.height = height;
this.width = width;
this.helpView = helpView;
this.gameMode = gameMode;
}
takeInput(){
this.mobileClick = <any>this.mobileClick.bind(this);
this.canvas.addEventListener('touchstart', this.mobileClick);
}
mobileClick(e){
var mobileClickX = e.targetTouches[0].pageX;
var mobileClickY = e.targetTouches[0].pageY;
/*
var mobileClickY = event.y;
mobileClickY -= this.canvas.offsetTop;
var mobileClickX = event.x;
mobileClickX -= this.canvas.offsetLeft;
*/
if(mobileClickY>this.height*250/640 &&mobileClickY<this.height*340/640 && mobileClickX< this.width*125/360 ){
if(this.gameMode == 1){
this.helpView.render(2);
this.gameMode = 2;
}
else{
this.helpView.render(1);
this.gameMode = 1;
}
}
else if(mobileClickY <this.height*100/640 && mobileClickX< this.width*100/360 ){
this.switchToMenuState();
}
}
/*
catClick(X,Y){
clearTimeout(this.menuView.animationOne);
this.notEnoughCat = false;
this.menuView.render(this.gameloop.currentGame);
}
*/
switchStates(){
this.canvas.removeEventListener('touchstart', this.mobileClick);
console.log("switching states");
}
switchToMenuState(){
this.switchStates();
this.gameloop.switchToMenuState();
}
}
}