Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tiled TMX import for HaxePunk
Haxe
Branch: master
Failed to load latest commit information.
com/haxepunk/tmx Fix TxmObjectGroup
README.md Readme typo, Fix #14
haxelib.json Update to 1.0.3 (HaxePunk 2.5.3)

README.md

HaxePunk Tiled

Add your maps to project.xml

<assets path="assets/maps" rename="maps" include="*.tmx" />

Load a map layers and collision

To use this as a background image simply create a new instance of TmxEntity.

import com.haxepunk.tmx.TmxEntity;

public function createMap()
{
  // create the map
  var e = new TmxEntity("maps/mylevel.tmx");

  // load layers named bottom, main, top with the appropriate tileset
  e.loadGraphic("graphics/tileset.png", ["bottom", "main", "top"]);

  // loads a grid layer named collision and sets the entity type to walls
  e.loadMask("collision", "walls");

  add(e);
}

Access properties and objects

To access map properties and object layers create an instance of TmxMap. To add it to the scene simply pass the TmxMap object to the TmxEntity constructor.

import com.haxepunk.tmx.TmxEntity;
import com.haxepunk.tmx.TmxMap;

public function createMap()
{
    // create the map
    var map = TmxMap.loadFromFile("maps/mylevel.tmx");

    // access map properties
    var prop = map.properties.resolve("myCustomProperties");

    // go through the list of objects in an object layer
    for(object in map.getObjectGroup("myObjectsLayer").objects)
    {
        // you can access:
        object.name; 
        object.type;

        object.x;
        object.y;

        object.width;
        object.height;

        // to read custom properties
        object.custom.resolve("myProp");
    }

    // create the map
    var e = new TmxEntity(map);

    // load layers named bottom, main, top with the appropriate tileset
    e.loadGraphic("graphics/tileset.png", ["bottom", "main", "top"]);

    // loads a grid layer named collision and sets the entity type to walls
    e.loadMask("collision", "walls");

    add(e);
}

MIT License

Copyright (C) 2012-2013 Matt Tuttle (original by Thomas Jahn)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.