Jump to content

Camera coordinate flooring


Cless
 Share

Recommended Posts

Hi. It appears that camera coordinate values are automatically floored. Thus, if I type:

 

game.camera.x = 20.5;

 

Then it will be changed to 20. Is there a way to prevent this behavior? If one uses tweening to move a followed sprite, then the camera transition looks very jittery. This is because the sprite may have a coordinate with a fraction, but the camera drops the fraction.

 

Looking at the code, it appears this flooring occurs on line 302 of Phaser.Camera in checkBounds:

 

this.view.floor();

Link to comment
Share on other sites

My apologies, the problem actually appears to be caused by the call to floor *and* the behavior of focusOnXY:

 

focusOnXY: function (x, y) {
 
            this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight));
 
}
 
(Removing the calls to Math.round and the call to floor fixes the issue.)
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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