Vinay Chaudhary Posted October 26, 2020 Share Posted October 26, 2020 The Script is being made for Animation of the Sprite Sheet with its movement. Using this script you can do this task. The Explanation of the script is given for everything you this you can understand this easily. Their is a " Docs file " attached with it. explanation of Script is given in it with attached image. var config = { type: Phaser.AUTO, width: 800, height: 600, gravity: { x: 0, y: 0, debug: false, }, parent: 'phaser-example', physics: { default: 'arcade' }, backgroundColor: 0x27ae60, scene: { preload: preload, create: create, update: update } }; var mummy; var cursors; var game= new Phaser.Game(config); function preload () { this.load.spritesheet('mummy', 'assets/running.png', {frameWidth: 125, frameHeight:150, endFrame: 10}); } function create () { cursors = this.input.keyboard.createCursorKeys(); this.anims.create( { key: 'left', frames: this.anims.generateFrameNumbers('mummy', { start: 0, end: 20 }), frameRate: 15, repeat: -1 }); mummy = this.add.sprite(200, 200, 'mummy'); mummy.anims.play('left', true); } function update () { if (cursors.right.isDown) { if (mummy.x !=700) { mummy.x += 0.5; } } } Animation and SpriteSheet Movement.docx Link to comment Share on other sites More sharing options...
Recommended Posts