Sakthivadivel

Sprites are shaking while moving from right to left

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

Share this post


Link to post
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. 

Share this post


Link to post
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.

 

Share this post


Link to post
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? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.