-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
88 lines (76 loc) · 2.2 KB
/
main.js
File metadata and controls
88 lines (76 loc) · 2.2 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
requirejs.config({
baseUrl: 'bower_components',
paths: {
src: '../src',
zepto: 'zepto/zepto',
createjs: 'easeljs/lib/easeljs-0.8.0.combined',
tweenjs: 'TweenJS/lib/tweenjs-0.6.0.combined',
soundjs: 'SoundJS/lib/soundjs-0.6.0.combined',
alertify: 'alertify.js/lib/alertify'
},
shim: {
'zepto': {
exports: '$'
},
'createjs': {
exports: 'createjs'
},
'tweenjs': {
deps: ['createjs'],
exports: 'createjs.Tween'
},
'soundjs': {
deps: ['createjs'],
exports: 'createjs.Sound'
}
}
});
// Start the main app logic
requirejs([
'createjs',
'tweenjs',
'src/Stage',
'src/Game',
'src/Canvas',
'src/GameStatus',
'src/DeviceEventManager',
'src/LevelManager',
'src/GameInfo',
'src/Sound',
'src/config',
'src/utils'
],
function(createjs, tweenjs, Stage, Game, Canvas, GameStatus, DeviceEventManager, LevelManager, GameInfo, Sound,
config, utils){
"use strict";
var htmlCanvasElement = document.querySelector('#canvas'),
canvas = new Canvas(htmlCanvasElement),
createJSStage = new createjs.Stage(htmlCanvasElement),
deviceEventManager = new DeviceEventManager(),
levelManager = new LevelManager(),
sound = new Sound(),
gameInfo = new GameInfo(sound),
stage = new Stage(createJSStage, canvas.getWidth(), canvas.getHeight()),
game = new Game(stage, levelManager, gameInfo),
fps = utils.isCordovaApp() ? 30 : utils.isMobileDevice() ? 45 : 60;
createjs.Touch.enable(createJSStage);
createjs.Ticker.setFPS(fps);
createjs.Ticker.addEventListener('tick', createJSStage);
console.log("FPS: " + fps);
deviceEventManager.onMenu(function () {
if(!game.isPaused()){
game.pause();
gameInfo.displayResetMessage(
function () {
game.restart();
},
function () {
game.resume();
}
);
}
});
setTimeout(function () {
game.start();
}, 500);
});