Closed BendyGaming0 closed 1 month ago
The provided code snippet does not reproduce the issue, when tested.
Perhaps your actual failing program is calling resetState
directly in create
rather on an event, which I do not recommend doing
Found the issue. resetState
was being passed into Void->Void
variable that was called twice due to an oversight by the original developer, it wasn't noticed before as calling resetState
twice did not throw an error prior to state switching changes. Sorry!
Because the
state.destroy()
function is always called on the current state byFlxGame
when switching or resetting states, it always throws an error when using a maker function forNextState
as it calls the overwrittenstate._constructor
field inNextState.createInstance()
Code snippet reproducing the issue:
Observed behavior: FlxState throws an error saying that the state has been destroyed while attempting to use resetState
Expected behavior: The current state (
PlayState
) would be restarted using the previously passed inNextState
maker function byFlxG.switchState()
somewhere else