Jump to content

Sprites are shaking while moving from right to left


Sakthivadivel
 Share

Recommended Posts

Hi All,

         I have developed a game using phaser JS.  In which I want to move sprites from right to left .I done it with sprite.body.velocity.x  (Decrease sprite's x value in update() also works fine).It moves fine. But while moving it is not smooth , the sprites look shaking  How to overcome this.

Please  anyone help me.

Thanks,

Sakthi

Link to comment
Share on other sites

I'm assuming you're doing spritesheet animation along with the movement.

99% of the times a sprite would shake if it's part of a spritesheet is the way it is positioned in the spritesheet, maybe the frame is offset by a few pixels in the spritesheet making it look shaky.

Otherwise I would encourage you to make bodies visible and see if it has anything to do with your movement code. 

Link to comment
Share on other sites

Hi WiLD11 ,

                        Thanks for your reply.But I'm not doing any spritesheet animation with that particular sprite. I just loaded a png image and created group of sprites as follows. 

game.load.image('enemy', 'assets/images/enemies.png');
enemies = game.add.group();
enemies.enableBody = true;
enemies.physicsBodyType = Phaser.Physics.ARCADE;
enemies.setAll('checkWorldBounds', true);
enemies.setAll('outOfBoundsKill', true);
var enemy=enemies.create(1220,game.rnd.realInRange((50),(game.world.height-350)), 'enemy', 0);
enemy.body.velocity.x = -1000;

Thanks,

Sakthi.

 
Link to comment
Share on other sites

15 hours ago, Sakthivadivel said:

Hi WiLD11 ,

                        Thanks for your reply.But I'm not doing any spritesheet animation with that particular sprite. I just loaded a png image and created group of sprites as follows. 

game.load.image('enemy', 'assets/images/enemies.png');
enemies = game.add.group();
enemies.enableBody = true;
enemies.physicsBodyType = Phaser.Physics.ARCADE;
enemies.setAll('checkWorldBounds', true);
enemies.setAll('outOfBoundsKill', true);
var enemy=enemies.create(1220,game.rnd.realInRange((50),(game.world.height-350)), 'enemy', 0);
enemy.body.velocity.x = -1000;

Thanks,

Sakthi.

 

Could you post a gif/video of whats happening? 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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