-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.js
45 lines (32 loc) · 1.35 KB
/
engine.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
// window.onload = function() {
var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.CANVAS, '', { preload: preload, create: create });
function preload() {
game.load.json('gamejson', 'games/card-suarez.json');
}
function create() {
gamejson = game.cache.getJSON('gamejson');
game.plugins.json2game = new Phaser.Plugin.JSON2Game(game);
game.plugins.json2game.create(gamejson);
}
function resize() {
var height = window.innerHeight;
var width = window.innerWidth;
var bounds = new Phaser.Rectangle(0, 0, width, height);
game.renderer.view.style.position = "absolute";
game.renderer.view.style.top = "0px";
game.renderer.view.style.left = "0px";
game.renderer.resize(width, height);
if (game.renderType === 1) {
Phaser.Canvas.setSmoothingEnabled(game.context, false);
}
game.camera.setSize(width, height);
game.camera.bounds = bounds;
game.world.bounds = bounds;
game.width = width;
game.height = height;
game.stage.width = width;
game.stage.height = height;
if (game.plugins.json2game) game.plugins.json2game.resize();
}
window.onresize = resize;
// };