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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.