Jump to content

How to code phaser game on html


Mizukage
 Share

Recommended Posts

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

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

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

 Share

  • Recently Browsing   0 members

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