Partial map layer that doesn't fill entire entire map area - TMX map



  • Hi,

    I am trying to have a background layer that spans the full size of the map with partial maps that don't span the full length of the map. In the Tiled editor, my tmx file shows correctly (the grey squares with pink border should be on the lefthand side of the map):

    0_1597334009800_97c54fd8-3d22-4466-9b8c-5f51ef181dbd-image.png

    But in my HaxeFlixel game, the map is rendered as (ignore pause button and button at the bottom):

    0_1597334126461_2ccea94a-2fe3-40ae-93d9-e9040ffc0aae-image.png

    My map file is defines the layers as:

    Background, full-width layer (notice 40 column width):

     <layer id="1" name="Background" width="40" height="20">
      <properties>
       <property name="nocollide" value="true"/>
       <property name="tileset" value="level"/>
      </properties>
      <data encoding="csv">
    <!-- 40 column data -->
    </data>
    

    Foreground, partial-width layer (notice 20-column width):

     <layer id="2" name="Foreground" width="20" height="20">
      <properties>
       <property name="nocollide" value="true"/>
       <property name="tileset" value="level"/>
      </properties>
      <data encoding="csv">
    <!-- 20 column  data -->
    </data>
    

    It's pretty clear what is happening: HaxeFlixel is rendering the 20-column foreground layer as if it were 40 columns (this cuts the layer in half, as shown in the second screenshot above).

    Is it possible for HaxeFlixel to render the foreground as being a 20-column layer instead of a 40-column layer? If so, how can this be done?

    Thanks!



  • I discovered the answer shortly after posting this, but for anyone that stumbles upon this, the issue was in how I was loading the map. I needed to change:

    var tileLayer:TiledTileLayer = cast layer;
    var tilemap:FlxTilemap = new FlxTilemap();
    tilemap.loadMapFromArray(tileLayer.tileArray, width, height, ...);
    

    to

    var tileLayer:TiledTileLayer = cast layer;
    var tilemap:FlxTilemap = new FlxTilemap();
    tilemap.loadMapFromArray(tileLayer.tileArray, tileLayer.width, tileLayer.height,  ...);
    

    The original version was using width from the TiledMap, which is the full map width. The second version uses this layer's width. Simple fix!



  • @mjedmonds said in Partial map layer that doesn't fill entire entire map area - TMX map:

    I discovered the answer shortly after posting this, but for anyone that stumbles upon this, the issue was in how I was loading the map. I needed to change:

    var tileLayer:TiledTileLayer = cast layer;
    var tilemap:FlxTilemap = new FlxTilemap();
    tilemap.loadMapFromArray(tileLayer.tileArray, width, height, ...);
    

    to

    var tileLayer:TiledTileLayer = cast layer;
    var tilemap:FlxTilemap = new FlxTilemap();
    tilemap.loadMapFromArray(tileLayer.tileArray, tileLayer.width, tileLayer.height,  ...);
    

    The original version was using width from the TiledMap, which is the full map width. The second version uses this layer's width. Simple fix!

    Thanks man! It worked


Log in to reply
 

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