2
\$\begingroup\$

First off, it's my first time doing a little bit of game development, and I have no idea of the normal flow of making a game, let alone a browser game.

My game uses the phaser framework of HTML and JavaScript. It is a simple game based on the 2D space impact game. I was able to run the game on an empty HTML site with only head, title, and body tags.

This is the code to plug in my game to the blank HTML site:

<script type="text/javascript" src="game.js" type="text/javascript"></script>

But when I tried to add it to my pre-made website, it won't show. Am I missing anything? Do I need to put it in an iFrame, although I know phaser builds on a canvas.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Did you verify that you game JS file is actually found and loaded (and no errors/exceptions occurred) for example with the inbuilt network tools modern browsers have? \$\endgroup\$ – Philip Allgaier Dec 18 '14 at 13:36
  • \$\begingroup\$ hmmm does running it on my another html page rule out errors? ill have a look and tell you. thanks \$\endgroup\$ – Gokigooooks Dec 18 '14 at 13:41
  • 1
    \$\begingroup\$ When it works in a very simple HTML document but not in a very complex one, there must be something in your complex document which prevents it from working. It is impossible for us to guess it. So what you need to do is continually remove more and more stuff from your actual website until you find the thing which prevents it from working. Then we can help you to find out why this thing prevents it from working. \$\endgroup\$ – Philipp Dec 18 '14 at 19:55
  • 1
    \$\begingroup\$ I'm not sure how you are creating your game within game.js, but don't forget to specify the parent option with an ID or element, so that Phaser knows where to put your game. I think if you don't specify that, it will just throw it at the end of your body tag, which probably isn't ideal. More notes on parent here: docs.phaser.io/Phaser.Game.html \$\endgroup\$ – jackrugile Dec 19 '14 at 0:22
3
\$\begingroup\$

Thanks for the help. I solved my own problem. it seems that a simpler way to put it would have to place the game on another html page and then embed it with an iFrame tag! like

<iframe src="game.html" height="550" width="800">game not available</iframe>

And the text "game not available" is a displayed text when the iFrame fails no embed the content from the source as a DEFAULT.

The reason for this problem might have been the conflicting javascript libraries of the Twitter bootstrap im using and the js library of the phaser framework.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.