Raza Posted July 12, 2016 Share Posted July 12, 2016 I'm having trouble making the using the JSON file to slice the spritesheet so that I'm able to make an animation. The sprites are not mine btw. Any help is appreciated on how I can make my code work. Game.js index.html phaser.min.js sprites.json Link to comment Share on other sites More sharing options...
stupot Posted July 15, 2016 Share Posted July 15, 2016 Hi, I've editied your game.js, commented out some problem code and added the setup to get physics working. Should get you going Stu var gameState = { preload: function() { this.game.load.atlasJSONHash('sprites', "sprites.png", "sprites.json"); }, create: function() { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.world.setBounds(0, 0, this.game.world.width, this.game.world.height); var row, sprite, x, y; // this.state = state1; // this.game = state.game; row = this.game.rnd.integerInRange(0, 6); x = this.game.world.width; // y = this.state.yForRow(row); // this.row = row; sprite = this.game.add.sprite(x, y, 'sprites', 'zombie1.png'); sprite.animations.add('walking', ["zombie1.png", "zombie2.png", "zombie3.png"], 5, true, false); sprite.animations.play('walking'); this.game.physics.arcade.enable(sprite); sprite.body.velocity.setTo(-20, 0); } }; Link to comment Share on other sites More sharing options...
Recommended Posts