Skip to content

Instantly share code, notes, and snippets.

@sergey-miryanov
Last active December 30, 2015 05:39
Show Gist options
  • Save sergey-miryanov/7784273 to your computer and use it in GitHub Desktop.
Save sergey-miryanov/7784273 to your computer and use it in GitHub Desktop.
Sampel of flixel bitmap cache usage
private static function getSpriteImpl(filename : String, width : Float,
resize : IResizeBitmapData) : FlxSprite
{
var key = resize.key(filename, width);
if(!FlxG.bitmap.checkCache(key))
{
if(cacheWarning)
{
trace([filename, key, "Not found"]);
}
var b = resize.bitmap(filename, width);
if(b != null)
{
var cachedGraphics = FlxG.bitmap.add(b, true, key);
cachedGraphics.persist = true;
}
}
var s = new FlxSprite(0, 0);
return s.loadGraphic(key, false, false, 0, 0, false, key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment