8
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

17
\$\begingroup\$

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.

\$\endgroup\$
1
  • 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\$
    – House
    Sep 18, 2013 at 15:25
1
\$\begingroup\$

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.

\$\endgroup\$
1
  • 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\$ Sep 18, 2013 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .