Add a check around an optional function

My game crashes here if I update phaser.js to a new version. It happens
when my game switches to another State object.