Jump to content

Animation and SpriteSheet Movement


Vinay Chaudhary
 Share

Recommended Posts

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 gamenew Phaser.Game(config);
function preload ()
{    
  this.load.spritesheet('mummy''assets/running.png', {frameWidth: 125frameHeight:150endFrame: 10});
}
function create ()
{
  cursors = this.input.keyboard.createCursorKeys();
    this.anims.create(
      {
        key: 'left',
        frames: this.anims.generateFrameNumbers('mummy', { start: 0end: 20 }),
        frameRate: 15,
        repeat: -1
      });      
 mummy = this.add.sprite(200200'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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...