1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-03 04:04:16 +00:00

Fix crash caused when game tries to render disposed sprites during a Sticker transition.

This commit is contained in:
EliteMasterEric 2024-04-10 14:45:07 -04:00
parent dbcbb73338
commit 6f5c3a043f
8 changed files with 21 additions and 13 deletions

View file

@ -47,9 +47,13 @@ class FunkinCamera extends FlxCamera
public var shouldDraw:Bool = true;
public function new(x:Int = 0, y:Int = 0, width:Int = 0, height:Int = 0, zoom:Float = 0)
// Used to identify the camera during debugging.
final id:String = 'unknown';
public function new(id:String = 'unknown', x:Int = 0, y:Int = 0, width:Int = 0, height:Int = 0, zoom:Float = 0)
{
super(x, y, width, height, zoom);
this.id = id;
bgTexture = pickTexture(width, height);
bgBitmap = FixedBitmapData.fromTexture(bgTexture);
bgFrame = new FlxFrame(new FlxGraphic('', null));

View file

@ -1467,7 +1467,7 @@ class PlayState extends MusicBeatSubState
*/
function initCameras():Void
{
camGame = new FunkinCamera();
camGame = new FunkinCamera('playStateCamGame');
camGame.bgColor = BACKGROUND_COLOR; // Show a pink background behind the stage.
camHUD = new FlxCamera();
camHUD.bgColor.alpha = 0; // Show the game scene behind the camera.

View file

@ -2091,7 +2091,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
loadPreferences();
uiCamera = new FunkinCamera();
uiCamera = new FunkinCamera('chartEditorUI');
FlxG.cameras.reset(uiCamera);
buildDefaultSongData();
@ -5382,7 +5382,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Kill and replace the UI camera so it doesn't get destroyed during the state transition.
uiCamera.kill();
FlxG.cameras.remove(uiCamera, false);
FlxG.cameras.reset(new FunkinCamera());
FlxG.cameras.reset(new FunkinCamera('chartEditorUI2'));
this.persistentUpdate = false;
this.persistentDraw = false;

View file

@ -513,7 +513,7 @@ class FreeplayState extends MusicBeatSubState
// var swag:Alphabet = new Alphabet(1, 0, 'swag');
var funnyCam:FunkinCamera = new FunkinCamera(0, 0, FlxG.width, FlxG.height);
var funnyCam:FunkinCamera = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height);
funnyCam.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(funnyCam);

View file

@ -172,7 +172,7 @@ class MainMenuState extends MusicBeatState
function resetCamStuff()
{
FlxG.cameras.reset(new FunkinCamera());
FlxG.cameras.reset(new FunkinCamera('mainMenu'));
FlxG.camera.follow(camFollow, null, 0.06);
FlxG.camera.snapToTarget();
}

View file

@ -48,7 +48,7 @@ class ControlsMenu extends funkin.ui.options.OptionsState.Page
{
super();
menuCamera = new FunkinCamera();
menuCamera = new FunkinCamera('controlsMenu');
FlxG.cameras.add(menuCamera, false);
menuCamera.bgColor = 0x0;
camera = menuCamera;

View file

@ -21,7 +21,7 @@ class PreferencesMenu extends Page
{
super();
menuCamera = new FunkinCamera();
menuCamera = new FunkinCamera('prefMenu');
FlxG.cameras.add(menuCamera, false);
menuCamera.bgColor = 0x0;
camera = menuCamera;

View file

@ -247,10 +247,6 @@ class StickerSubState extends MusicBeatSubState
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
// TODO: Rework this asset caching stuff
FunkinSprite.preparePurgeCache();
FunkinSprite.purgeCache();
// I think this grabs the screen and puts it under the stickers?
// Leaving this commented out rather than stripping it out because it's cool...
/*
@ -265,7 +261,15 @@ class StickerSubState extends MusicBeatSubState
// FlxG.addChildBelowMouse(dipshit);
*/
FlxG.switchState(() -> targetState(this));
FlxG.switchState(() -> {
// TODO: Rework this asset caching stuff
// NOTE: This has to come AFTER the state switch,
// otherwise the game tries to render destroyed sprites!
FunkinSprite.preparePurgeCache();
FunkinSprite.purgeCache();
return targetState(this);
});
}
});
});