Hello World Phaser Example

Kudos Thomas Palef: http://www.lessmilk.com/ http://blog.lessmilk.com/how-to-make-flappy-bird-in-html5-1/

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js"></script>
<div id="game_div"></div>

CSS

#game_div {
        width: 400px;
        margin: auto;
        margin-top: 50px;
    }

JavaScript

// Initialize Phaser, and creates a 400x490px game
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');
var gameshowroom = {};

// Creates a new 'main' state that wil contain the game
gameshowroom = function (game) {
};

gameshowroom.prototype = {
    
    preload: function () {
      this.game.load.image('hello', 'https://s3.amazonaws.com/uploads-1969f46zwpmbh5cm3kr2/hello.png');
    },
    
    create: function () {
      socketConnect();
    }
};

function showBtn() {
  console.log("This: " + game);
  game.hello = game.add.sprite(100, 10, 'hello');
}

function socketConnect() {
    setTimeout(function() {
      showBtn();
    },2000);
}

// Add and start the 'main' state to start the game
game.state.add('main', gameshowroom);
game.state.start('main');