From 7ebc7e4ffbccf1b70ed83b1960762a9d89f07fdd Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 8 Jun 2021 23:05:38 -0400 Subject: [PATCH] quick title screen optimize --- source/PlayState.hx | 8 ++++++++ source/TitleState.hx | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/source/PlayState.hx b/source/PlayState.hx index 560e4dd99..cecedd341 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2732,6 +2732,14 @@ class PlayState extends MusicBeatState }); } + override function switchTo(nextState:FlxState):Bool + { + openfl.utils.Assets.cache.clear(Paths.inst(SONG.song)); + openfl.utils.Assets.cache.clear(Paths.voices(SONG.song)); + + return super.switchTo(nextState); + } + function noteMiss(direction:Int = 1):Void { // whole function used to be encased in if (!boyfriend.stunned) diff --git a/source/TitleState.hx b/source/TitleState.hx index 4c793684a..05e6863d7 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -465,6 +465,13 @@ class TitleState extends MusicBeatState FlxG.sound.play(Paths.sound('confirmMenu'), 0.7); transitioning = true; // FlxG.sound.music.stop(); + + // These assets are very unlikely to be used for the rest of gameplay, so it unloads them from cache/memory + // Saves about 50mb of RAM or so??? + Assets.cache.clear(Paths.image('gfDanceTitle')); + Assets.cache.clear(Paths.image('logoBumpin')); + Assets.cache.clear(Paths.image('titleEnter')); + #if newgrounds if (!OutdatedSubState.leftState) {