# How to use doors in Tiled?

**URL:** <https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057>\
**Category:** Questions\
**Created:** [April 13, 2021, 9:25am UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057 "2021-04-13T09:25:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_JE\_Cooke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/richard_je_cooke/32/3244_2.png) [@Richard\_JE\_Cooke](https://discourse.mapeditor.org/u/Richard_JE_Cooke)\
**Post date:** [April 13, 2021, 9:25am UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057/1 "2021-04-13T09:25:41Z")

</div>

Hi, what’s the best way to include doors in a map (i.e. any interactive element)?

I was hoping to make them a tile instance with a custom property like `locked` or `key_number`, but tiles can’t have custom properties ☹

So then I have to specify each door as an object in an object layer - and somehow figure out in Phaser how to map that pixel-specific location to the closest tile location, put a door there, and link it to code to animate it for opening and closing. And also then I can’t see the doors in the map builder. I can’t really think of a decent way without tiles having custom data.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [April 13, 2021, 10:18am UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057/2 "2021-04-13T10:18:15Z")

</div>

You can place the tile graphic itself as an object (using the “Insert Tile” tool). That way you can put custom properties on it _and_ you can see the door in the editor.

---

<div class="post-metadata">

**Author:** ![Richard\_JE\_Cooke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/richard_je_cooke/32/3244_2.png) [@Richard\_JE\_Cooke](https://discourse.mapeditor.org/u/Richard_JE_Cooke)\
**Post date:** [April 13, 2021, 10:35am UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057/3 "2021-04-13T10:35:52Z")

</div>

Oh, this is great, thank you. I don’t know how I missed this in the docs.  
Is there any reason not to use object layers for everything, and disregard tile layers entirely?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [April 13, 2021, 11:30am UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057/4 "2021-04-13T11:30:35Z")

</div>

> [@Richard\_JE\_Cooke](#):
>
> Is there any reason not to use object layers for everything, and disregard tile layers entirely?

This is mainly a performance consideration. On a tile layer, each tile only takes 32 bits (in the file format, a bit more while in memory because the tile pointer is resolved), because its location is defined by its index in the tiles array. In contrast each object stores its location and a bunch of other properties, so objects are more heavy-weight. It is also trivial to determine which tiles should be drawn and in which order, whereas freely placed objects may need more complex data structures and sorting.

Still, with today’s hardware there is indeed often no reason to resort to tile layers, and some people create their levels entirely using objects.

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [April 13, 2021, 4:33pm UTC](https://discourse.mapeditor.org/t/how-to-use-doors-in-tiled/5057/5 "2021-04-13T16:33:20Z")

</div>

From an authoring standpoint, tile layers offer some advantages as well. Because the editor can assume tiles are confined to the grid, it can offer tools like a bucket fill, Terrains, etc. With objects, these tools either don’t make sense or are ambiguous in the general case.

Many of the authoring automation tools Tiled provides only make sense for and work with tile layers. So, while in the end, it might not make a huge\* difference whether you use objects or tiles, for authoring, using tiles for those tasks where they’re appropriate can save you a lot of work.

\* The difference _can_ be large enough to be noticeable even on modern hardware, depending on the assumptions the _engine_ makes about tiles versus objects. If the engine treats all objects as dynamic even if they’re not (a fairly reasonable assumption if the engine supports tilemaps and other structures to handle static visuals), it’ll be rebuilding the sprite batch(es) and sending them to the GPU far more than it would need to, in addition to possibly running (fruitless) update logic on them. This can quickly add up to noticeable framerate dips and high CPU/GPU usage.
