-
Notifications
You must be signed in to change notification settings - Fork 480
Description
Proposal is to call subState.close();
here. Flixel clearly wants this sub state gone, it calls its closeCallback
, and the state's subStateClosed
signal, but it never actually finishes the job and calls close
on the sub state.
The fact that closing a sub state, (specifically by opening a new one!!) doesn't call the original sub state's close
method has personally caused me a really hard to debug issue.
I have some code from one of my projects that I used to work around this issue, but not only does it use Reflect
but I also believe it is generally a pretty confusing piece of code that could be removed if FlxState
properly called the close
method in the scenario mentioned.
Here is the aforementioned code with some comments to hopefully help explain what the issue is:
override function openSubState(newSubState:FlxSubState):Void
{
super.openSubState(newSubState);
var typeOf:Class<FlxSubState> = Type.getClass(newSubState);
// If the sub state trying to open ISN'T of type `CustomTransition`, proceed.
if (typeOf != CustomTransition)
{
// Get type of currently closing sub state.
typeOf = Type.getClass(subState);
/**
* We set `persistentUpdate` to false here because Flixel has internally already closed the `CustomTransition`
* sub state, but it hasn't (and won't) dispatched the sub state's `close` method, which WOULD set this to false.
* Therefore, we have to do it ourselves here.
*/
if (typeOf == CustomTransition)
persistentUpdate = false;
}
}
TLDR: Flixel should call subState.close();
in resetSubState
because Flixel calls several related methods and the currently this not being implemented can cause some issues.
Sorry if this issue is a bit confusing, it's one that's sort of hard to convey. If there's any clarification I can offer let me know.