Jump to content

Tweened sprite movement is jerky while camera is moving


mccxiv
 Share

Recommended Posts

Hi friends, any idea why the sprite seems to jump around as soon as the camera begins moving?

It happens with both `game.camera.follow(player);` and the smooth camera you see in the demo.
And also happens with both `game.renderer.renderSession.roundPixels` set to true and false...

It's not a CPU/GPU issue as far as I can tell, the rest of the game is running smoothly.

Pt9WobM.gif

Movement code: 

  function moveToNextTile() {
    if (isDead()) return;
    state.moving = true;
    faceNextTile();
    setWalkingAnimation();
    const {x, y} = World.instance.toPixel(nextTile());
    const tween = Game.instance.add.tween(state.sprite);
    tween.to({x, y}, 400);
    tween.onComplete.addOnce(onNewTile);
    tween.start();
  }

 

Link to comment
Share on other sites

Upperfoot, I think what you're seeing is the frame or two in between successive tweens. Like, tween 1 is running, then a frame or two, then tween 2 picks up. I'm seeing the sprite jump with no camera movement, and changing all those values to 23 or 92 produce jumps at 23 or 92 pixels.

Link to comment
Share on other sites

Browserquest! You might test with movement done manually by setting x and y in a the update function. Also test your frame rates too!

game.time.advancedTiming = true;
game.debug.text(game.time.fps, 2, 14, "#00ff00");

 

Link to comment
Share on other sites

Thanks guys but it seems the issue only presents itself when the camera follows the sprite while it's tweening, if the camera has a dead zone there is no jerky movement as the camera isn't moving while the sprite is tweening, but as soon as it's outside the dead zone the jerky movement starts, if you look at the above gif by mccxiv you can see this happening clear as day.

My FPS is a solid 60 and has advanced timing enabled, tried with round pixels being enabled and many other configurations.

There is a github issue on the matter. 

https://github.com/photonstorm/phaser/issues/2482

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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