forked from expo/expo-phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.js
44 lines (33 loc) · 945 Bytes
/
Game.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
import ExpoPhaser from 'expo-phaser';
import Playable from './states/Playable';
export default class Game {
constructor(props) {
const { context, gamePause, updateStats } = props;
const game = ExpoPhaser.game({ context });
this.playable = new Playable({ context, game, gamePause, updateStats });
game.state.add('Playable', this.playable);
game.state.start('Playable');
this.onTouchesBegan = this.onTouchesBegan.bind(this);
this.onTouchesEnded = this.onTouchesEnded.bind(this);
}
updateControls(velocity) {
if (this.playable) {
this.playable.updateControls({ velocity });
}
}
onTouchesBegan() {
if (!this.playable) {
return false;
}
return this.playable.onTouchesBegan();
}
onTouchesEnded() {
if (!this.playable) {
return false;
}
return this.playable.onTouchesEnded();
}
onTogglePause(paused) {
this.playable.pauseGame(paused);
}
}