1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-08-20 23:45:04 +00:00

memory optimizations

This commit is contained in:
Cameron Taylor 2021-06-07 21:14:50 -04:00
parent 2323000381
commit 2db47b1ba9
3 changed files with 31 additions and 4 deletions

View file

@ -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');

View file

@ -194,6 +194,13 @@ class Note extends FlxSprite
}
}
override function destroy()
{
prevNote = null;
super.destroy();
}
public function updateColors():Void
{
colorSwap.update(arrowColors[noteData]);

View file

@ -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;