Mizukage Posted August 19, 2015 Share Posted August 19, 2015 I have a problem, I'm not sure how code game made on phaser 'canvas' in html. Because<div id="gameContainer"></div>...var game = new Phaser.Game(1000, 600, Phaser.AUTO, 'gameContainer');Look odious... How to do that in better looking way? Link to comment Share on other sites More sharing options...
Pooya72 Posted August 19, 2015 Share Posted August 19, 2015 whats odious ? this is my index.html for example : <html> <head> <title> Hit enemies</title> <script src="assets/phaser.min.js"></script> <script src="main.js"></script> <script src="game.js"></script> <script src="menu.js"></script> </head> <body> <div id="Hello" align="center"></div> <script> var game = new Phaser.Game(800,700,Phaser.AUTO,'Hello'); game.state.add('gameState',gameState); game.state.add('menuState',menuState); game.state.start('menuState'); </script> </body></html> Link to comment Share on other sites More sharing options...
Noid Posted August 20, 2015 Share Posted August 20, 2015 That's the way you do it. In your HTML you define how the webpage containing the game is going to be structured. You also define a div element where you want to insert the game. Then, in your javascript, which may be part of the html file or on one or many separate js files, you need to tell phaser where to attach the canvas.Why do you think it's ugly? Link to comment Share on other sites More sharing options...
Recommended Posts