Jump to content

2.0.5 camera bug


tesserex
 Share

Recommended Posts

I apologize if this is in the wrong place.

 

I just upgraded from 2.0.2 to 2.0.5, and I was having a weird problem where my sprites that were off camera were never getting drawn when I moved. I thought it was something I was doing wrong as I had changed my code but some digging shows this looks like a bug.

 

Here is some chrome debugger output I did, inside the context of a sprite's update function. "c" is the sprite. All of this was entered while stopped at a single breakpoint. My camera is 800 x 600.

 

c.x
120
c.y
-280
c.game.camera.x
77
c.game.camera.y
-452
c.inCamera
false
c.game.camera.screenView
 
Phaser.Rectangle {x0y0width800height600offsetfunction}
 

So you can see, my sprite is at 120, -280, which is clearly inside the camera's bounds. The inCamera property is implemented using screenView, but screenView is still over at the origin for some reason. Instead the camera's "view" property is correct.

 

c.game.camera.view
 
Phaser.Rectangle {x77y-452width800height600offsetfunction}
c.game.camera.view.intersects(c.getBounds())
true

 

Link to comment
Share on other sites

Actually I noticed that the camera.view was also incorrect. It seems to be the case that the sprite update method is called during a point when the necessary bounds and camera properties have not been updated yet. I ended up having to implement an equivalent inCamera myself. If it's supposed to be the case that you can't rely on these things during the update method, that might be ok (though I think we should be able to) but it should at least be in the documentation somewhere.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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