Passing A Music Object Between States In A Phaser Game Engine
My question is specific about Phaser game engine So I have a game with a few states and each state is defined like: var myGame = {}; myGame.Boot = function (game) { }; myGame.Bo
Solution 1:
- Global vars:
You could actually define these on myGame
. While it uses a different way of defining these, take a look at the Full Screen Mobile Template that's part of the Phaser codebase itself. The creator of Phaser actually recommended this on their forums for declaring 'global' variables.
That gives you something like this:
myGame.fx = game.add.audio('sfx');
// ...
- Global cache:
Good question. The only thing I've found is breaking the MP3 files up and loading them into the cache individually. In that way your cache has an object with that name/key.
But if you add these to your myGame
object, you should be able to keep your audio in a single file.
Post a Comment for "Passing A Music Object Between States In A Phaser Game Engine"