Tiled Tile Map Editor

repository·master·Indexed 11 days ago

https://github.com/mapeditor/tiled

A flexible, general-purpose tile map editor for tile-based games. Supports arbitrary map sizes, layers, and custom properties using the TMX format. Includes a scripting API with TypeScript definitions via @mapeditor/tiled-api v1.11.0, automapping features, and Java integration through libtiled.

Tokens
48.7K
Snippets
77
Records
273
Agent score
95%

What's inside Tiled

  1. Use the Java library to add Tiled map support

    master
    The libtiled-java library provides source code that allows you to integrate Tiled map file support into your Java projects. For a reference implementation of how to use the library, you can examine the tmx-viewer-java sample project, which uses libtiled-java to render and view Tiled map files.
  2. What is Automapping in Tiled?

    master

    Automapping allows you to automatically place or replace tiles based on user-defined rules. The system scans your working map for tiles that match a rule's input and automatically places the corresponding output tiles. This is useful for automating repetitive decoration or correcting placement mistakes.

    Key usage modes:

    • Manual: Apply rules via Map > AutoMap.
    • Dynamic: Enable Map > AutoMap While Drawing to apply rules automatically as you paint tiles.

    Important Note for New Rules: If you are creating new rules, do not use regions layers. Using regions layers will trigger the legacy Automapping system, which may cause rules to behave unexpectedly. For corner and edge tile automation (like terrain shapes), consider using Terrains instead.

  3. Overview of Tiled features and layer types

    master

    Tiled is a 2D level editor supporting various map types and annotation methods:

    Tile Maps

    Supports straight rectangular, projected isometric, staggered isometric, staggered hexagonal, and oblique layers. Editing is primarily done via a stamp brush for painting, drawing lines/circles, and using automatic terrain transitions or pattern-matching (automapping).

    Object Layers

    Used for annotating levels or placing images. Unlike tile layers, object placement is not restricted to the tile grid. Supported object types include:

    • Rectangle
    • Point
    • Ellipse
    • Polygon
    • Polyline
    • Tile objects

    Objects can be scaled and rotated to provide high flexibility for game data and visual elements.

  4. Use Wang Sets for advanced terrain/edge tiling

    master

    Wang sets are a flexible way to define terrain and edge transitions. They replace the deprecated <terraintypes> element.

    <wangsets> Structure

    A <wangsets> element contains multiple <wangset> elements.

    <wangset> Attributes

    • name: Name of the Wang set.
    • class: The class of the Wang set (defaults to "").
    • tile: The tile ID representing this Wang set.

    <wangcolor> Attributes

    Defines a color used for corners or edges.

    • name: Name of the color.
    • class: The class of the color (defaults to "").
    • color: Hex color in #RRGGBB format.
    • tile: The tile ID representing this color.
    • probability: Relative probability of selection (defaults to 1).

    <wangtile> Attributes

    Associates a tile with a Wang ID.

    • tileid: The tile ID.
    • wangid: A comma-separated list of indexes (0-254) referring to Wang colors in the order: top, top-right, right, bottom-right, bottom, bottom-left, left, top-left. (Index 0 is unset).
  5. Use QtSingleApplication to restrict applications to a single instance

    master
    The QtSingleApplication component is a Qt solution designed for applications that should only have one active instance running per user. It manages instance detection and allows a new instance to communicate with the existing one (e.g., for window raising or message handling) instead of starting a duplicate process.
  6. Understand the two types of tilesets

    master

    Tiled supports two distinct tileset models, chosen at creation time:

    1. Based on Tileset Image: Defines a fixed tile size and a single source image. It supports margin (space around the whole image) and spacing (space between tiles) to handle extruded borders or gaps.
    2. Collection of Images: Each tile refers to its own individual image file. This is ideal for tiles of varying sizes or when texture packing is handled by an external process.

    Note: It is recommended to save tilesets as external files (rather than embedding them in a map file) so that meta-information is shared across all maps using that tileset.

  7. Use Tile Property Inheritance and Typed Tiles

    master

    Tiled supports property inheritance to simplify data management for repetitive assets.

    Tile Property Inheritance

    When you add properties to a tile, those properties are inherited by any object instance of that tile.

    • Inherited properties are displayed in gray (disabled text color).
    • Overridden properties (set specifically on the object instance) are displayed in black.

    Typed Tiles

    To avoid setting properties on every single object instance, you can use Typed Tiles:

    1. Define a custom class (e.g., "NPC", "Enemy", or "Item") with properties like health or weight.
    2. Set this class on the tile itself.
    3. When you place that tile as an object, the predefined properties are automatically available, and you can override them for specific instances if needed.
  8. Manage editor state with Session files

    master

    Each Tiled project is associated with a *.tiled-session file stored alongside the project file.

    Key characteristics of session files:

    • Purpose: They store your last opened files, the last editor state for those files, and the last used parameters in various dialogs.
    • Sharing: Session files should generally not be shared with others.
    • Behavior: When you switch projects, Tiled automatically switches to the associated session file so you can resume your previous work. If no project is loaded, Tiled uses a global session file.
  9. How Tile Layers are exported to GameMaker

    master

    Tiled tile layers are mapped to GameMaker features based on their configuration:

    • Standard Tile Layers: Exported as tile layers when possible. However, because GameMaker supports only one tileset per tile layer, if a single Tiled layer uses multiple tilesets, it will be exported as a group containing a child tile layer for each tileset.
    • Asset Layers (Fallback): A tile layer will fall back to an asset layer if:
      • The tileset tile size does not match the map grid size.
      • The map orientation is not orthogonal (e.g., isometric or hexagonal).
      • The layer uses tiles from a 'collection of images' tileset (these export as sprite graphics).
    • Note on Rotation: Asset layers in GameMaker do not support rotation for tile graphics. If 90-degree rotation is needed, use standard tile layers. For free rotation, use a collection of images tileset to export as sprite graphics.
  10. Optimize large worlds by showing only adjacent maps

    master

    For extremely large worlds that cause memory or rendering issues, you can instruct Tiled to only load the current map and its direct neighbors.

    To enable this, add "onlyShowAdjacentMaps": true to the top-level JSON object in your .world file.

    Note: When using this mode, you must define the size of each map in pixels so Tiled knows which maps are neighbors:

    • For manual maps: Use "width" and "height" properties.
    • For patterns: Use "mapWidth" and "mapHeight" properties (these default to the values of your multipliers if not specified).
    {
        "onlyShowAdjacentMaps": true,
        "maps": [
            {
                "fileName": "map1.tmx",
                "x": 0,
                "y": 0,
                "width": 1024,
                "height": 1024
            }
        ],
        "type": "world"
    }