add startOutro, deprecate switchTo #2768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
related to #2565
adds
startOutro
which is called fromFlxG.switchState
with a callback that - when called - triggers the actual switching.switchTo
is now deprecated because it doesn't work with the proposed changes for Flixel 6.0.0It's worth noting that this new system doesn't allow states to prevent switches, by evaluating the next state instance, but based on the name "switchTo" and how
switchTo
is currently used I don't think that was ever a desired feature, but rather a side-effect to how it was implemented, if devs want to use this kind of state flow control they can make some proprietary system for handling that.The Old Way
when
FlxG.switchState
is called, switchTo is called, a fade to black is started, after which stateSwitch is called again and it will actually switch states.Note: This way still works perfectly fine but overriding
switchTo
in a class that derives fromFlxState
will show the warning: "switchTo is deprecated, use startOutro".The New Way
In this way, startOutro simply passes the complete callback into the fade
Pretty sexy, if I do say so, myself.