Last active
August 29, 2015 14:01
-
-
Save steverichey/80d19de4d9269520e61c to your computer and use it in GitHub Desktop.
Drawing a FlxTilemap to a FlxSprite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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