|
| 1 | + |
| 2 | +BasicGame.Game = function (game) { |
| 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. |
| 25 | + |
| 26 | +}; |
| 27 | + |
| 28 | +BasicGame.Game.prototype = { |
| 29 | + |
| 30 | + create: function () { |
| 31 | + |
| 32 | + // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
| 33 | + |
| 34 | + }, |
| 35 | + |
| 36 | + update: function () { |
| 37 | + |
| 38 | + // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! |
| 39 | + |
| 40 | + }, |
| 41 | + |
| 42 | + quitGame: function (pointer) { |
| 43 | + |
| 44 | + // Here you should destroy anything you no longer need. |
| 45 | + // Stop music, delete sprites, purge caches, free resources, all that good stuff. |
| 46 | + |
| 47 | + // Then let's go back to the main menu. |
| 48 | + this.state.start('MainMenu'); |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | +}; |
0 commit comments