Jump to content

best way to include a phaser example in wordpress


pat
 Share

Recommended Posts

hello,

 

I want to include in my blog (wordpress), a short example in Phaser.

 

For example.

<!doctype html><html>    <head>        <meta charset="UTF-8" />        <title>hello phaser!</title>        <script src="phaser.min.js"></script>    </head>    <body>    <script type="text/javascript">    window.onload = function() {        var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });        function preload () {            game.load.image('logo', 'phaser.png');        }        function create () {            var logo = game.add.sprite(game.world.centerX, game.world.centerY, 'logo');            logo.anchor.setTo(0.5, 0.5);        }    };    </script>    </body></html>

What is the best place to upload the phaser library and the script ??

 

I was not able to find a little tutorial

Perhaps, the best idea is to use a plug-in ??

 

Thanks a lot

 

Patrick

Link to comment
Share on other sites

I think this is a question that should be directed towards WordPress forums rather than Phaser, as it's a general question about including JavaScript in a page. Normally you'd just upload your example to a standalone webpage and then link to it from your WordPress post. Embedding it in the page would require you to include the phaser.min.js in the page template, as well as the JavaScript for your example. 

Link to comment
Share on other sites

I used to write custom javascript for each page to load the games separately but it turned out to be cumbersome and not very maintainable. I now use the iframe plugin on the page to show the games (with proper dimensions to fit the game best). 

 

Crayon is very good for showing code examples too. :)

 

Plugins i use - http://wordpress.org/plugins/iframe/

https://wordpress.org/plugins/crayon-syntax-highlighter/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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