HillsOne = new FlxBackdrop("assets/single/HillsOne.png", 1, 0, true, false);
add(HillsOne);
var textureAtlas:SparrowData = new SparrowData(
"assets/sheets/Desktop.xml",
"assets/sheets/Desktop.png"
);
this.loadGraphicFromTexture(textureAtlas, false, 'HillsOne');
var frame:TextureAtlasFrame = null;for (i in 0...textureAtlas.frames.length){ if (textureAtlas.frames[i].name == "bg") { frame = textureAtlas.frames[i]; break; }}var textureRegion:TextureRegion = new TextureRegion(FlxG.bitmap.add(texture.asset), Math.floor(frame.frame.left), Math.floor(frame.frame.top), Math.floor(frame.frame.width), Math.floor(frame.frame.height), 0, 0, Math.floor(frame.frame.width), Math.floor(frame.frame.height));var backdrop:FlxBackdrop = new FlxBackdrop(textureRegion, 1, 1, true, true);
I think I meant textureAtlas.asset, textureAtlas being a TexturePackerXMLData , so it should be the same as your sparrowData. I didn't copy and paste from my stuff, I was writing on the fly but if that doesn't work I can check up exactly what I did when I get back home.
--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to a topic in the Google Groups "HaxeFlixel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/haxeflixel/IVgtrn_u-d8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/0506692d-ebe4-469a-893f-b63e8a6f8040%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package helpers;import flixel.addons.display.FlxBackdrop;import flixel.FlxG;import flixel.util.loaders.SparrowData;import flixel.util.loaders.TextureAtlasFrame;import flixel.util.loaders.TexturePackerXMLData;import flixel.util.loaders.TextureRegion;
/** * @author Shaun Stone (SMKS) */class AtlasImageExtractor{ public function new() {} /** * * @param name * @param textureAtlas * @return */ public static function getImageByName(name:String, textureAtlas:SparrowData):TextureRegion {
var frame:TextureAtlasFrame = null; for (i in 0...textureAtlas.frames.length) {
if (textureAtlas.frames[i].name == name)
{ frame = textureAtlas.frames[i]; break; } }
if (frame == null) { throw "Frame not found in atlas"; } return buildTextureRegion(frame); } /** * * @param frame * @return */ private static function buildTextureRegion(frame:TextureAtlasFrame):TextureRegion { var texture = new TexturePackerXMLData( PathAssets.getAtlasXml(), PathAssets.getAtlasAsset() );
var textureRegion:TextureRegion = new TextureRegion( FlxG.bitmap.add(texture.asset), Math.floor(frame.frame.left), Math.floor(frame.frame.top), Math.floor(frame.frame.width), Math.floor(frame.frame.height), 0, 0, Math.floor(frame.frame.width), Math.floor(frame.frame.height) );
return textureRegion; } }
package helpers;
import flixel.addons.display.FlxBackdrop;import flixel.FlxG;import flixel.util.loaders.SparrowData;import flixel.util.loaders.TextureAtlasFrame;import flixel.util.loaders.TexturePackerXMLData;import flixel.util.loaders.TextureRegion;
/**
* This is used to do the FlxBackdrop using an atlas instead * of a single image *
* @author Shaun Stone (SMKS) */class AtlasImageExtractor{ public function new() {} /** * * @param name * @param textureAtlas * @return */ public static function getImageByName(name:String, textureAtlas:SparrowData):TextureRegion { var frame:TextureAtlasFrame = null; for (i in 0...textureAtlas.frames.length) { if (textureAtlas.frames[i].name == name) { frame = textureAtlas.frames[i]; break; } } if (frame == null) { throw "Frame not found in atlas"; }
return buildTextureRegion(frame, textureAtlas);
} /** * * @param frame * @return */
private static function buildTextureRegion(frame:TextureAtlasFrame, textureAtlas:SparrowData):TextureRegion {
var textureRegion:TextureRegion = new TextureRegion(
FlxG.bitmap.add(textureAtlas.asset),