title: How do I import a sprite sheet with its JSON file into my phaser game?
body: <p>I am creating a game using the phaser game engine. I created a sprite sheet and downloaded it. It came with the 256 × 384 .png file with my frames and a JSON file which I assume contains information about how to split up the frames. I don't know how to import the sprite sheet with the JSON file into my preload() function. I tried using the following code but it is not working. Any help would be greatly appreciated. </p>
  
  <pre><code>var game = new Phaser.Game(1200, 750, Phaser.AUTO, '', { preload:   preload, create: create, update: update });
  function preload(){
      game.load.image('background', 'assets2/background.png');
      game.load.json('robot', 'assets2/VillainSpriteSheet_json.json');
      game.load.spritesheet('robot', 'assets2/VillainSpriteSheet.png');
  }
  
  var villain; 
  
  function create(){
  
  var villainjson = game.cache.getJSON('robot');
  
  //enable physics
  game.physics.startSystem(Phaser.Physics.ARCADE);
  
  //create background
  var background = game.add.sprite(0, 0, 'background');
  
  //villain
  villain = game.add.sprite(50, 50, 'robot');
  
  //enable phsyics 
  game.physics.arcade.enable(villain);
  villain.body.bounce.y = .2;
  villain.body.gravity.y = 300; 
  villain.body.collideWorldBounds = true;  
  
  
  }
  </code></pre>