Last active
August 29, 2015 14:19
-
-
Save aberloni/61c8b276afea811a5386 to your computer and use it in GitHub Desktop.
A haxeflixel class to transform a bitmap file on the user harddrive (absolute path) to FlxSprite
This file contains hidden or 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
package; | |
import flixel.FlxG; | |
import flixel.FlxSprite; | |
import flixel.group.FlxGroup; | |
import flixel.util.FlxColor; | |
import flash.display.BitmapData; | |
/** | |
* ... | |
* @author a.berlemont | |
* https://github.com/HaxeFlixel/flixel-demos/blob/master/User%20Interface/FileBrowse/source/PlayState.hx | |
*/ | |
class AtlasBrowser extends FlxGroup | |
{ | |
public function new() | |
{ | |
super(); | |
getAsset("C:\Users\[user]\Desktop\[file].jpg"); | |
} | |
function getAsset(path:String):Void { | |
var sp:FlxSprite = new FlxSprite(); | |
add(sp); | |
var data:BitmapData = BitmapData.load(path); | |
var imgWidth:Float = FlxG.width / data.width; | |
var imgHeight:Float = FlxG.height / data.height; | |
sp.makeGraphic(Std.int(data.width), Std.int(data.height), FlxColor.BLACK); | |
sp.pixels = data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment