Another Invalid field access : __s issue.

  • Hey guys,
    I was working trough the book Discover Haxeflixel ( Anyways there's a chapter where we use a level loader class to load a level created in Tiled to the state. When I try to use this code I always get an error: Invalid field access : __s. .... I've spent a couple of hours now trying to solve this problem and for the life of me I can't. I put all the code on github (plus a big-ish Export folder (sorry about that)). Would any of you please be so kind as to try and take I look at this problem, I've pretty much ran out of ideas at this point... I know it has something to do with __s (string?) but I really don't know how to debug this case properly. Thanks in advance.

  • administrators

    You seem to have a separate .tsx file for the tile set in your assets/data folder. I haven't seen that before, I'm not sure if the Tiled integration in flixel-addons supports that. Is there an option somewhere that embeds the tile set into the .tmx file?

  • Hey, I found out that this problem exists solely with neko builds, I have tried now flash, html5 and cpp and all except neko work fine. I find that kind of strange since I used neko up to that point exclusively (for debugging purposes)...
    EDIT: I had to downgrade hxcpp version since it wouldn't work with default install. Can't remember where I've read instructions though, probably somewhere on this forum.

  • 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[0].firstGID;
    			for (tileset in tileMap.tilesetArray)
    				if ("remove"))
    					removeTilesets = true;
    				if (!removeTilesets)
    					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);

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.