Skip to content

Commit 263b9fd

Browse files
author
Thomas
committed
small tweaks
1 parent 1fbbd12 commit 263b9fd

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

1-introduction/empty-project.zip

0 Bytes
Binary file not shown.

1-introduction/hello-world.zip

25 Bytes
Binary file not shown.

1-introduction/hello-world/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
// Parameters: width of the game, height of the game, how to render the game, the name of the div in the html that will contain the game
44
var game = new Phaser.Game(500, 600, Phaser.AUTO, 'game_div');
55

6-
// An array to store the different states of our game (play, menu, credits, etc.)
6+
// An array to store the different states of our game. A state is a specific scene of a game like a menu, a game over screen, etc.
77
var game_state = {};
88

9-
// Let's define our first state: play
10-
game_state.play = function(game) { };
11-
game_state.play.prototype = {
9+
// Let's define our first state. I'll call it 'main' since we only have one.
10+
game_state.main = function(game) { };
11+
game_state.main.prototype = {
1212

1313
preload: function() {
14-
// Everything in this function will be executed at the beginning. That’s where we usually load the game’s assets (images, sounds, etc.)
15-
14+
// Everything in this function will be executed at the beginning. That’s where we usually load the
15+
1616
// Load a sprite in the game
1717
// Parameters: name of the image, path to the image
1818
game.load.image('hello', 'assets/hello.png');
1919
},
2020

2121
create: function() {
22-
// This function will be called after the preload function. Here we set up the game: place sprites, add labels, etc.
22+
// This function will be called after the preload function. Here we set up the game, display sprites, add labels, etc.
2323

2424
// Display a sprite on the screen
2525
// Parameters: x position, y position, name of the sprite
2626
hello_sprite = game.add.sprite(250, 300, 'hello');
2727
},
2828

2929
update: function() {
30-
// This is where you will spend the most of your time. This function is called 60 times per seconds to update the state of your game.
30+
// This is where we will spend the most of our time. This function is called 60 times per second to update the game.
3131

3232
// Increase the angle of the sprite by one
3333
hello_sprite.angle += 1;
3434
}
3535
}
3636

37-
// And we tell Phaser to add and start our play state
38-
game.state.add('play', game_state.play);
39-
game.state.start('play');
37+
// And finally we tell Phaser to add and start our 'main' state
38+
game.state.add('main', game_state.main);
39+
game.state.start('main');

0 commit comments

Comments
 (0)