I have a question regarding map editors, like Tiled, for example. I am currently making my own map editor, and I wondered if someone could explain to me what is the purpose of layering in tiled for example. What purpose does it serve in creating a map?


Layers are needed not only the most basic use of a tile map, but also allow more artistic expression and play features. Layers define the draw order of the sprites used in your world. They're simply a way to say, "Draw sprite X after sprite Y, so that sprite X will appear on top of sprite Y". They're typically generalized into layers so you don't need to define the depth for each sprite (though you could also think of defining the depth as setting the layer). This process is referred to as the Painter's Algorithm.

The most basic use is from having the player (or any non-map item) on top of the map. The map is one layer, and the player and other items are in another layer on top of the map.

enter image description here

(Source for image is a nice tutorial for making a simple game)

The artistic expression and play features include allowing players to walk "behind" other objects in the world or have placeable structures/items.

Layers are not only limited to visuals. You can also have layers that define non-walkable areas, like in the example above, layer 3 could be defined as "blocking" meaning the player isn't allowed to move onto anything in that layer. This effectively creates player boundaries to help with map creation. This can expand to the physics system where you may only want some sprites to collide with sprites in their same layer. This is a simple way of disabling friendly fire for example.

Layers also allow for effects like parallax scrolling. This gives a 2D game a feeling of depth.

  • 6
    \$\begingroup\$ Don't accept the answer too soon. Something better may come along. Waiting to accept an answer encourages others to answer and overall provides a better resource for future visitors. \$\endgroup\$ – MichaelHouse Sep 18 '13 at 15:25

Having different layers makes it possible to have things that the character can walk "behind" by putting the part in front of the player. This article explains this fairly well.

  • 2
    \$\begingroup\$ Correct, but maybe also mention the painter's algorithm and entity layers in your answer? I know the tutsplus article touches on it, but it's best to actually write out a full answer since you never know when a webpage you cite may disappear. \$\endgroup\$ – michael.bartnett Sep 18 '13 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.