pat Posted August 20, 2014 Share Posted August 20, 2014 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 tutorialPerhaps, the best idea is to use a plug-in ?? Thanks a lot Patrick megan 1 Link to comment Share on other sites More sharing options...
lewster32 Posted August 20, 2014 Share Posted August 20, 2014 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 More sharing options...
pat Posted August 20, 2014 Author Share Posted August 20, 2014 Thanks a lot for your answer As a lot of users here, have a blog showing phaser examples, I was thinking that a user can give me what was the best idea to do that. Link to comment Share on other sites More sharing options...
rich Posted August 20, 2014 Share Posted August 20, 2014 To display the source code there are loads of Wordpress plugins you can get. Crayon syntax highlighter is my favourite. To embed an actual example you just use an iframe and point it at the code which you will have needed to upload somewhere. Or use a site like codepen. megan 1 Link to comment Share on other sites More sharing options...
Nambiar Posted August 21, 2014 Share Posted August 21, 2014 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/ megan 1 Link to comment Share on other sites More sharing options...
Recommended Posts