|
1 | 1 |
|
2 | 2 | BasicGame.Game = function (game) { |
3 | 3 |
|
4 | | - // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: |
5 | | - |
6 | | - this.game; // a reference to the currently running game |
7 | | - this.add; // used to add sprites, text, groups, etc |
8 | | - this.camera; // a reference to the game camera |
9 | | - this.cache; // the game cache |
10 | | - this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) |
11 | | - this.load; // for preloading assets |
12 | | - this.math; // lots of useful common math operations |
13 | | - this.sound; // the sound manager - add a sound, play one, set-up markers, etc |
14 | | - this.stage; // the game stage |
15 | | - this.time; // the clock |
16 | | - this.tweens; // the tween manager |
17 | | - this.state; // the state manager |
18 | | - this.world; // the game world |
19 | | - this.particles; // the particle manager |
20 | | - this.physics; // the physics manager |
21 | | - this.rnd; // the repeatable random number generator |
22 | | - |
23 | | - // You can use any of these from any function within this State. |
24 | | - // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference. |
| 4 | + // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: |
| 5 | + |
| 6 | + this.game; // a reference to the currently running game (Phaser.Game) |
| 7 | + this.add; // used to add sprites, text, groups, etc (Phaser.GameObjectFactory) |
| 8 | + this.camera; // a reference to the game camera (Phaser.Camera) |
| 9 | + this.cache; // the game cache (Phaser.Cache) |
| 10 | + this.input; // the global input manager. You can access this.input.keyboard, this.input.mouse, as well from it. (Phaser.Input) |
| 11 | + this.load; // for preloading assets (Phaser.Loader) |
| 12 | + this.math; // lots of useful common math operations (Phaser.Math) |
| 13 | + this.sound; // the sound manager - add a sound, play one, set-up markers, etc (Phaser.SoundManager) |
| 14 | + this.stage; // the game stage (Phaser.Stage) |
| 15 | + this.time; // the clock (Phaser.Time) |
| 16 | + this.tweens; // the tween manager (Phaser.TweenManager) |
| 17 | + this.state; // the state manager (Phaser.StateManager) |
| 18 | + this.world; // the game world (Phaser.World) |
| 19 | + this.particles; // the particle manager (Phaser.Particles) |
| 20 | + this.physics; // the physics manager (Phaser.Physics) |
| 21 | + this.rnd; // the repeatable random number generator (Phaser.RandomDataGenerator) |
| 22 | + |
| 23 | + // You can use any of these from any function within this State. |
| 24 | + // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference. |
25 | 25 |
|
26 | 26 | }; |
27 | 27 |
|
28 | 28 | BasicGame.Game.prototype = { |
29 | 29 |
|
30 | | - create: function () { |
| 30 | + create: function () { |
31 | 31 |
|
32 | | - // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
| 32 | + // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
33 | 33 |
|
34 | | - }, |
| 34 | + }, |
35 | 35 |
|
36 | | - update: function () { |
| 36 | + update: function () { |
37 | 37 |
|
38 | | - // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
| 38 | + // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
39 | 39 |
|
40 | | - }, |
| 40 | + }, |
41 | 41 |
|
42 | | - quitGame: function (pointer) { |
| 42 | + quitGame: function (pointer) { |
43 | 43 |
|
44 | | - // Here you should destroy anything you no longer need. |
45 | | - // Stop music, delete sprites, purge caches, free resources, all that good stuff. |
| 44 | + // Here you should destroy anything you no longer need. |
| 45 | + // Stop music, delete sprites, purge caches, free resources, all that good stuff. |
46 | 46 |
|
47 | | - // Then let's go back to the main menu. |
48 | | - this.state.start('MainMenu'); |
| 47 | + // Then let's go back to the main menu. |
| 48 | + this.state.start('MainMenu'); |
49 | 49 |
|
50 | | - } |
| 50 | + } |
51 | 51 |
|
52 | 52 | }; |
0 commit comments