drawOffset is reset to 0, 0 when game is paused

This seems to be new behavior in 3.0.2. Testing with 3.0.1 it works as it always has.

When accessing graphics.getDrawOffset in gameWillPause, it will always be 0,0 regardless of the current value set by the game.

The offset is restored when you close the pause menu - it is only 0,0 when the menu is opened.

This introduced a problem for me that took a minute to track down - I use the drawOffset as the camera location, and save its value when the game is paused. This change resulted in the game storing the camera location as 0 when the game is saved, so resuming a saved game later did not restore the scene correctly. i.e., if the player saved while on the far right side of the scene, when restoring the game from save data they would be on the far left side (camera at 0 rather than -800 for example). I’ve worked around it by keeping a reference to the most recent value rather than accessing the API directly when saving state.

So not a big deal, but since its a new behavior I thought I’d let you know!

Easiest way to to reproduce:

  • Create a project that sets the draw offset to an arbitrary coordinate.
  • In gameWillPause print graphics.getDrawOffset()
  • Pause the game.
  • In 3.0.2 it will be 0,0 and in lower versions, it will be that offset you defined.

I believe this is the same core issue as this: Menu - Lock - Unlock doesn't redraw the original screen

Ah, great - so if it is, it should be fixed in 3.0.3. Thanks Will!

It's related but not exactly the same. To fix it we'd have to move the gameWillPause call after resetting the draw state--which is probably how we should have done it in the first place, but I think making that change at this point is likely to cause more surprise bugs elsewhere. It really is an accident that the draw offset was leaking into the gameWillPause handler, so I think tracking the offset yourself is the cleaner solution.

Noted - thanks Dave!