Phaser 3

by Luis Martin

HTML

<script src="https://github.com/photonstorm/phaser/releases/download/v2.6.1/phaser.min.js"></script>
<div id="game_div"> </div>

CSS

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

JavaScript

//https://github.com/photonstorm/phaser-examples/tree/master/examples/assets/sprites

//http://phaser.io/sandbox/NUpUhphz


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

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

  preload: function() {
    game.load.baseURL = 'https://i.imgur.com/';
    game.load.crossOrigin = 'anonymous';
    game.load.spritesheet('mummy', 'v7TnZGX.png', 37, 45, 18);

    game.load.image('sky', 'TKCXe08.png');

  },

  create: function() {
    //this.add.image(0, 0, 'sky');
    var mummy = game.add.sprite(0, 0, 'mummy');

    var walk = mummy.animations.add('walk');
    //mummy.animations.play('walk', 30, true);
  },

  update: function() {

  }
};

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