mdicamp Posted November 30, 2015 Share Posted November 30, 2015 Hi! I have several mini- games and wanted to put on canvas hum Only today do one for each . These mini games are on a map and being chamdos by links. I wonder if I can do this . Link to comment Share on other sites More sharing options...
drhayes Posted December 1, 2015 Share Posted December 1, 2015 Yes, you probably can. Or: are you having a problem doing it? Link to comment Share on other sites More sharing options...
mdicamp Posted December 1, 2015 Author Share Posted December 1, 2015 Yes I 'm having problems because there are several mini games now the structure is as follows:general map - index.html - canvas Phaser src/boot.js src/preload.js src/game.js containing links to 6 mini Games each with its structure and calling his canvas. game/index.html - canvas Phaser game/src/boot.js game/src/preload.js 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 More sharing options...
Gob0 Posted December 1, 2015 Share Posted December 1, 2015 just run this line one : var game = new Phaser.Game (1000 , 600, Phaser.CANVAS , '') ;then use one GameState per mini game and switch state on user choice. Link to comment Share on other sites More sharing options...
mdicamp Posted December 1, 2015 Author Share Posted December 1, 2015 Would look like this : <html><head><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></head><body><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); game.state.start('Boot');})();</script></body></html> But I did not so, because I have more games to add. I have another solution? Link to comment Share on other sites More sharing options...
Gob0 Posted December 1, 2015 Share Posted December 1, 2015 You can use introspection to replace all game.state.add by a loop. But this won't change the reality: your game will have at least 3 states per mini game. Link to comment Share on other sites More sharing options...
mdicamp Posted December 1, 2015 Author Share Posted December 1, 2015 How would it be? Link to comment Share on other sites More sharing options...
Gob0 Posted December 1, 2015 Share Posted December 1, 2015 Take a look at this Honestly, i'm not sure using introspection & reflection will change your app. But it's your call. Link to comment Share on other sites More sharing options...
Recommended Posts