Jump to content

single canvas for several mini games


Recommended Posts

Yes I 'm having problems because there are several mini games now the structure is as follows:

general map - index.html - canvas Phaser





containing links to 6 mini Games each with its structure and calling his canvas.

                        game/index.html - canvas Phaser



                        game/ src/game.js


for so I am calling 7 times var game = new Phaser.Game (1000 , 600, Phaser.CANVAS , '') ;


I wanted to call once, but how am I going to do if the navigation is a link and did not want to call the scripts all at once on the map index as it should be done?

Link to comment
Share on other sites

Would look like this :



<script src="src/MapBoot.js"></script>
<script src="src/MapPreloader.js"></script>
<script src="src/MapGame.js"></script>

<script src="game1/src/game1Boot.js"></script>
<script src="game1/src/game1Preloader.js"></script>
<script src="game1/src/game1Game.js"></script>


<script src="game6/src/game6Boot.js"></script>
<script src="game6/src/game6Preloader.js"></script>
<script src="game6/src/game6Game.js"></script>

<script type="text/javascript">

(function () {

    var game = new Phaser.Game(1000, 600, Phaser.CANVAS, '');

    game.state.add('Boot', Map.Boot);
    game.state.add('Preloader', Map.Preloader);
    game.state.add('Game', Map.Game);

    game.state.add('game1Boot', game1.Boot);
    game.state.add('game1Preloader', game1.Preloader);
    game.state.add('game1Game', game1.Game);

    game.state.add('game2Boot', game2.Boot);
    game.state.add('game2Preloader', game2.Preloader);
    game.state.add('game2Game', game2.Game);


    game.state.add('game6Boot', game6.Boot);
    game.state.add('game6Preloader', game6.Preloader);
    game.state.add('game6Game', game6.Game);





But I did not so, because I have more games to add. I have another solution?

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...