mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-05-23 07:31:16 +00:00
Merge pull request #481 from FunkinCrew/bugfix/draw-crash
Fix crash caused when game tries to render disposed sprites during a Sticker transition.
This commit is contained in:
commit
f8240e926e
|
@ -47,9 +47,13 @@ class FunkinCamera extends FlxCamera
|
||||||
|
|
||||||
public var shouldDraw:Bool = true;
|
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);
|
super(x, y, width, height, zoom);
|
||||||
|
this.id = id;
|
||||||
bgTexture = pickTexture(width, height);
|
bgTexture = pickTexture(width, height);
|
||||||
bgBitmap = FixedBitmapData.fromTexture(bgTexture);
|
bgBitmap = FixedBitmapData.fromTexture(bgTexture);
|
||||||
bgFrame = new FlxFrame(new FlxGraphic('', null));
|
bgFrame = new FlxFrame(new FlxGraphic('', null));
|
||||||
|
|
|
@ -1470,7 +1470,7 @@ class PlayState extends MusicBeatSubState
|
||||||
*/
|
*/
|
||||||
function initCameras():Void
|
function initCameras():Void
|
||||||
{
|
{
|
||||||
camGame = new FunkinCamera();
|
camGame = new FunkinCamera('playStateCamGame');
|
||||||
camGame.bgColor = BACKGROUND_COLOR; // Show a pink background behind the stage.
|
camGame.bgColor = BACKGROUND_COLOR; // Show a pink background behind the stage.
|
||||||
camHUD = new FlxCamera();
|
camHUD = new FlxCamera();
|
||||||
camHUD.bgColor.alpha = 0; // Show the game scene behind the camera.
|
camHUD.bgColor.alpha = 0; // Show the game scene behind the camera.
|
||||||
|
|
|
@ -2185,7 +2185,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
|
|
||||||
loadPreferences();
|
loadPreferences();
|
||||||
|
|
||||||
uiCamera = new FunkinCamera();
|
uiCamera = new FunkinCamera('chartEditorUI');
|
||||||
FlxG.cameras.reset(uiCamera);
|
FlxG.cameras.reset(uiCamera);
|
||||||
|
|
||||||
buildDefaultSongData();
|
buildDefaultSongData();
|
||||||
|
@ -5709,7 +5709,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.
|
// Kill and replace the UI camera so it doesn't get destroyed during the state transition.
|
||||||
uiCamera.kill();
|
uiCamera.kill();
|
||||||
FlxG.cameras.remove(uiCamera, false);
|
FlxG.cameras.remove(uiCamera, false);
|
||||||
FlxG.cameras.reset(new FunkinCamera());
|
FlxG.cameras.reset(new FunkinCamera('chartEditorUI2'));
|
||||||
|
|
||||||
this.persistentUpdate = false;
|
this.persistentUpdate = false;
|
||||||
this.persistentDraw = false;
|
this.persistentDraw = false;
|
||||||
|
|
|
@ -517,7 +517,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
|
|
||||||
// var swag:Alphabet = new Alphabet(1, 0, 'swag');
|
// 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;
|
funnyCam.bgColor = FlxColor.TRANSPARENT;
|
||||||
FlxG.cameras.add(funnyCam);
|
FlxG.cameras.add(funnyCam);
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ class MainMenuState extends MusicBeatState
|
||||||
|
|
||||||
function resetCamStuff()
|
function resetCamStuff()
|
||||||
{
|
{
|
||||||
FlxG.cameras.reset(new FunkinCamera());
|
FlxG.cameras.reset(new FunkinCamera('mainMenu'));
|
||||||
FlxG.camera.follow(camFollow, null, 0.06);
|
FlxG.camera.follow(camFollow, null, 0.06);
|
||||||
FlxG.camera.snapToTarget();
|
FlxG.camera.snapToTarget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ControlsMenu extends funkin.ui.options.OptionsState.Page
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
menuCamera = new FunkinCamera();
|
menuCamera = new FunkinCamera('controlsMenu');
|
||||||
FlxG.cameras.add(menuCamera, false);
|
FlxG.cameras.add(menuCamera, false);
|
||||||
menuCamera.bgColor = 0x0;
|
menuCamera.bgColor = 0x0;
|
||||||
camera = menuCamera;
|
camera = menuCamera;
|
||||||
|
|
|
@ -21,7 +21,7 @@ class PreferencesMenu extends Page
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
menuCamera = new FunkinCamera();
|
menuCamera = new FunkinCamera('prefMenu');
|
||||||
FlxG.cameras.add(menuCamera, false);
|
FlxG.cameras.add(menuCamera, false);
|
||||||
menuCamera.bgColor = 0x0;
|
menuCamera.bgColor = 0x0;
|
||||||
camera = menuCamera;
|
camera = menuCamera;
|
||||||
|
|
|
@ -247,10 +247,6 @@ class StickerSubState extends MusicBeatSubState
|
||||||
FlxTransitionableState.skipNextTransIn = true;
|
FlxTransitionableState.skipNextTransIn = true;
|
||||||
FlxTransitionableState.skipNextTransOut = 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?
|
// 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...
|
// 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.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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue