|
15 | 15 | var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); |
16 | 16 |
|
17 | 17 | function preload() { |
18 | | - game.load.image('mushroom', 'assets/sprites/mana_card.png'); |
| 18 | + game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png'); |
19 | 19 | } |
20 | 20 |
|
21 | 21 | var s; |
22 | | - var t; |
23 | 22 |
|
24 | 23 | function create() { |
25 | 24 |
|
26 | | - // Make our game world 2000x2000 pixels in size (the default is to match the game size) |
27 | | - game.world.setSize(2000, 2000); |
| 25 | + game.world._stage.backgroundColorString = '#182d3b'; |
28 | 26 |
|
29 | | - s = game.add.sprite(180, 400, 'mushroom'); |
30 | | - s.autoCull = true; |
31 | | - |
32 | | - // s.visible = false; |
33 | | - // t = game.time.now + 2000; |
34 | | - // s.scrollFactor.setTo(0.5, 0.5); |
| 27 | + s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk'); |
| 28 | + s.anchor.setTo(0.5, 0.5); |
35 | 29 |
|
36 | 30 | } |
37 | 31 |
|
38 | 32 | function update() { |
39 | 33 |
|
40 | | - // if (game.time.now > t && s.visible == false) |
41 | | - // { |
42 | | - // console.log('visible'); |
43 | | - // s.visible = true; |
44 | | - // } |
45 | | - |
46 | | - // s.rotation += 0.01; |
| 34 | + s.rotation += 0.01; |
47 | 35 |
|
48 | 36 | if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) |
49 | 37 | { |
50 | | - game.camera.x -= 4; |
| 38 | + s.x -= 4; |
51 | 39 | } |
52 | 40 | else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) |
53 | 41 | { |
54 | | - game.camera.x += 4; |
| 42 | + s.x += 4; |
55 | 43 | } |
56 | 44 |
|
57 | 45 | if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) |
58 | 46 | { |
59 | | - game.camera.y -= 4; |
| 47 | + s.y -= 4; |
60 | 48 | } |
61 | 49 | else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) |
62 | 50 | { |
63 | | - game.camera.y += 4; |
| 51 | + s.y += 4; |
64 | 52 | } |
65 | 53 |
|
66 | 54 | } |
67 | 55 |
|
68 | 56 | function render() { |
69 | 57 |
|
70 | | - // game.debug.renderRectangle(game.world.camera.view, 'rgba(200,0,0,0.2)'); |
71 | | - // game.debug.renderRectangle(s.bounds); |
72 | | - game.debug.renderSpriteCorners(s, true); |
73 | | - |
74 | | - game.debug.renderSpriteInfo(s, 400, 32); |
75 | | - game.debug.renderWorldTransformInfo(s, 32, 32); |
76 | | - // game.debug.renderLocalTransformInfo(s, 200, 32); |
77 | | - game.debug.renderCameraInfo(game.world.camera, 32, 200); |
| 58 | + game.debug.renderSpriteCorners(s, true, true); |
| 59 | + game.debug.renderSpriteInfo(s, 20, 32); |
78 | 60 |
|
79 | 61 | } |
80 | 62 |
|
|
0 commit comments