mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-27 01:55:52 -05:00
memory optimizations
This commit is contained in:
parent
2323000381
commit
2db47b1ba9
3 changed files with 31 additions and 4 deletions
|
@ -1,11 +1,9 @@
|
|||
package;
|
||||
|
||||
#if discord_rpc
|
||||
import Discord.DiscordClient;
|
||||
#end
|
||||
import flash.text.TextField;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.math.FlxMath;
|
||||
|
@ -16,6 +14,10 @@ import lime.utils.Assets;
|
|||
|
||||
using StringTools;
|
||||
|
||||
#if discord_rpc
|
||||
import Discord.DiscordClient;
|
||||
#end
|
||||
|
||||
class FreeplayState extends MusicBeatState
|
||||
{
|
||||
var songs:Array<SongMetadata> = [];
|
||||
|
@ -247,6 +249,12 @@ class FreeplayState extends MusicBeatState
|
|||
}
|
||||
}
|
||||
|
||||
override function switchTo(nextState:FlxState):Bool
|
||||
{
|
||||
clearDaCache(songs[curSelected].songName);
|
||||
return super.switchTo(nextState);
|
||||
}
|
||||
|
||||
function changeDiff(change:Int = 0)
|
||||
{
|
||||
curDifficulty += change;
|
||||
|
@ -264,6 +272,19 @@ class FreeplayState extends MusicBeatState
|
|||
positionHighscore();
|
||||
}
|
||||
|
||||
// Clears the cache of songs, frees up memory, they'll have to be loaded in later tho
|
||||
function clearDaCache(actualSongTho:String)
|
||||
{
|
||||
for (song in songs)
|
||||
{
|
||||
if (song.songName != actualSongTho)
|
||||
{
|
||||
trace('trying to remove: ' + song.songName);
|
||||
openfl.Assets.cache.clear(Paths.inst(song.songName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeSelection(change:Int = 0)
|
||||
{
|
||||
NGio.logEvent('Fresh');
|
||||
|
|
|
@ -194,6 +194,13 @@ class Note extends FlxSprite
|
|||
}
|
||||
}
|
||||
|
||||
override function destroy()
|
||||
{
|
||||
prevNote = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public function updateColors():Void
|
||||
{
|
||||
colorSwap.update(arrowColors[noteData]);
|
||||
|
|
|
@ -30,7 +30,6 @@ class DebugBoundingState extends FlxState
|
|||
/*
|
||||
TODAY'S TO-DO
|
||||
- Cleaner UI
|
||||
- Loading the spritesheet and spritesheet data from offsetview
|
||||
*/
|
||||
var bg:FlxSprite;
|
||||
var fileInfo:FlxText;
|
||||
|
|
Loading…
Reference in a new issue