TiledMap has tilesetArray, from where one can read different tilesets, including external, but if several tilesets are wanted in one layer, one needs to merge them. I have some big old snippet for this:
var tileMap: TiledMap = new TiledMap(Xml.parse(tmxFile), "assets/data/");
//mapColliders = new FlxGroup();
var tileSize: FlxPoint = FlxPoint.get(tileMap.tileWidth, tileMap.tileHeight);
// merge tilesets into one
var tilesetTileFrames: Array<FlxTileFrames> = new Array<FlxTileFrames>();
var tilesetProperties: Map<Int, TiledPropertySet> = new Map<Int, TiledPropertySet>();
var removeTilesets: Bool = false;
var firstGid: Int = tileMap.tilesetArray.firstGID;
for (tileset in tileMap.tilesetArray)
removeTilesets = true;
var width = tileset.numCols * tileset.tileWidth;
var height = tileset.numRows * tileset.tileHeight;
tilesetTileFrames.push(FlxTileFrames.fromRectangle(Resource.LoadBitmap("assets/data/" + tileset.imageSource, width, height, 0xAA8A5A46, false), tileSize));
//tilesetTileFrames.push(Resource.LoadBitmapInAtlas("assets/data/" + tileset.imageSource, width, height, 0xAA8A5A46, atlas));
//trace("tileset.tileProps.length: " + tileset.tileProps.length);
for (i in 0...tileset.tileProps.length)
var propertySet = tileset.getProperties(i);
if (propertySet != null)
tilesetProperties[i + tileset.firstGID] = propertySet;
var tileSpacing: FlxPoint = FlxPoint.get(0, 0);
//var tileBorder: FlxPoint = FlxPoint.get(2, 2);
var tileBorder: FlxPoint = FlxPoint.get(0, 0);
var mergedTileset = FlxTileFrames.combineTileFrames(tilesetTileFrames/*, tileSpacing, tileBorder*/);
var node: FlxNode = atlas.addNode(mergedTileset.parent.bitmap, "combined tiles");
var combinedTileSize: FlxPoint = new FlxPoint(tileSize.x /*+ tileBorder.x * 2*/, tileSize.y /*+ tileBorder.y * 2*/);
var combinedTileFramesFromAtlas: FlxTileFrames = node.getTileFrames(combinedTileSize/*, tileSpacing, tileBorder*/);
for (i in 0...tilesetTileFrames.length)
tilesetTileFrames[i] = null;
mergedTileset = combinedTileFramesFromAtlas;
for (tileset in tileMap.tilesetArray)
FlxG.bitmap.removeByKey("assets/data/" + tileset.imageSource);
@claudio-ficara Thanks for the suggestions =) I tried my demo with these alterations and unfortunately the results are not much better. The FlxSpriteGroup does not seem to respond well to setGraphicSize() — for me, it disappears from the screen entirely (or fails to draw?).
I thought the center offset was a good idea, but using that method, the green and white FlxSprites are now centered on the lower-right corner of the red boxes. And the FlxText and FlxButtons now float away into negative space for the smaller sizes. One plus is that green and white FlxSprites do align better with each other though (i.e. the border is consistent for all sizes), so there might be something there if you had a group containing only FlxSprites.
Eventually, I gave in and decided to create a new FlxSpriteGroup and resize/re-position the group members individually, instead of trying to get HaxeFlixel to adjust the group as a whole. This works for me, since I don't have too many members in the group, so I guess this method solves my issue for now.
I did that and have pages of errors now. I need a better client for the command line to copy/paste them all. "export/windows/cpp/haxe/ApplicationMain.hx:80: characters 47-65 : Warning : Use programPath instead
Creating c:/Users/Bob/Hello World/export/windows/cpp/obj/obj/msvc16-ncxp/__pch/haxe/hxcpp.pch...
Is there a way to run it with errors?
Hola Agustin, muchas gracias por responder, voy a realizar la lectura del link que me pasas, quizás el sha1 que pasé es incorrecto. Por otro lado, para conseguir el NDK r16b la hice fácil, puse a descargar la versión 15, copié el vínculo, reemplacé el 5 por un 6 y salió una descarga de 801 Mb (cómo no se me ocurrió antes...).
Realizo la lectura y corroboro las configuraciones, la firma y el sha-1 y te comento como me fue.
FlxGroup can be added to other groups/states, so update() and draw() are called on all the members of the group with exists == true. Be careful, adding to two groups can lead to update() called twice resulting in 2x simulation speed (can be solved by marking the group active = false).
Use arrays when you don't want to update/draw sprites, or they are updated/drawn from other group already.
And also, as you said, use groups when APIs demand FlxGroup, like for object recycling or collision.
Ok. Commenting out the include in haxelib/hxcpp/3,4,64/src/hx/libs/std/Sys.cpp has fixed the issue. I am assuming this is safe to do as the next time I am required to update hxcpp this issue would be fixed.
I mean compilation surely should work with both VS2013 and VS2015. VS2010 has some problems, like processing assets for an hour, so I don't recommend it.
As I wrote this I also remembered that new VS versions don't install C++ compiler by default and only install C#, so C++ should be explicitly enabled by the user in the installer. (but if this is the case, Android builds should be broken too)
I'm developing a game built on FlxNestedSprite. The group positioning/scaling/rotating is really convenient, and is the kind you are looking for.
I can tell you my work around for your "Every Child Must be a FlxNestedSprite" issue.
I just created a base class that extends FlxNestedSprite, that has some logic built in to copy any other sprite, either on load, every frame, or when you need it to.
For example, FlxText, which cannot be added directly as a child to a FlxNestedSprite. I just use this helper class:
class FlxNestedTextSprite extends FlxNestedSprite
private var text:FlxText;
private var fontPath:String;
private var message:String;
private var textBoxAlign:String;
private var size:Int;
private var textColor:FlxColor;
public function new(message:String, fontPath:String,
this.message = message;
this.fontPath = fontPath;
this.size = size;
this.textColor = textColor;
this.textBoxAlign = textBoxAlign;
text = new FlxText(0, 0, 0, message);
text.setFormat(fontPath, size, textColor, "left");
private function copyFlxTextToSprite(destinationSprite:FlxSprite,
If you need to add some other non-FlxNestedSprite as a child, you can do something similar.
Hope that helps!
Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.