Skip to content

Instantly share code, notes, and snippets.

@steverichey
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steverichey/80d19de4d9269520e61c to your computer and use it in GitHub Desktop.
Save steverichey/80d19de4d9269520e61c to your computer and use it in GitHub Desktop.
Drawing a FlxTilemap to a FlxSprite
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.tile.FlxTilemap;
class Util
{
static public function renderTileMapToSprite(Tiles:FlxTilemap, Sprite:FlxSprite):Void
{
var tempCam:FlxCamera = new FlxCamera(0, 0, Std.int(Tiles.width), Std.int(Tiles.height));
Sprite.makeGraphic(Std.int(Tiles.width), Std.int(Tiles.height), 0);
Tiles.camera = tempCam;
Tiles.draw();
#if flash
Sprite.stamp(tempCam.screen);
#else
Sprite.pixels.draw(tempCam.canvas);
#end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment