Layering sprites (SOLVED)

How do you choose which sprite should display over the top of another, I tried messing around with the blend method but to no avail…

You can adjust the z position. If you wanted a game where objects closer to the player were in front you could adjust z based on the y position for example.

Example here

Basically, you want to update the z position for everything you draw to be at the right “layer” - you can segment groups based on z distance, and have very fine changes for z distance for example 0.47573 …

2 Likes

Clever, I thought the z coordinate was obsolete for 2D games

Defold is a full 3D engine. The tools are 2D oriented now though.

is there any way to view objects in 3D space yet?, or is the workspace viewport locked to 2D?

Defold’s editor can’t (for now at least…), but you could make a level editor with Defold that could for building content. Keep in mind that z index in default rendering script doesn’t change the perspective scale at all it’s only used for layering, but you can modify the rendering script to do anything any 3d engine can.

I want make a level editor like this sometime…

Especially features like this

1 Like

I know that it have been 3 years but so the King is using Defold as a 3D engine but we can only use it as a 2D engine right?

Nah, we are creating a 3D game with it. Works absolutely fine! King is not in any way using another version of the engine. It’s all the same.

5 Likes

I’ve made a lot of 3D tests with Defold. If there’s a kind of 3D game you want to make with Defold make a thread and we can offer suggestions on how to accomplish it.

2 Likes

Right now I don’t have a plan to create a 3D game with Defold but I read in somewhere that currently Defold editor only supports 2D then I wondered how to create a 3D game with it. If you know any tutorials about it if you can share with me, I will be gratitude.

Defold is primarily meant for 2D dev in that most of the productivity tools it has were made with 2D gamedev in mind (so far) but the point still stands that it is actually a 3D engine.

Check out this example for a very simple base for a first person shooter https://github.com/subsoap/fps

I have some 3D materials here DefMaterial - A Collection of 2D + 3D Materials

Although the built in model material stuff has changed since then so if you are making something for production you’ll want to study those and make any necessary changes.

2 Likes

The editor does support 3D now, though it’s very basic. Hold Ctrl and drag with the left mouse button to rotate the viewport camera. (And press . to reset it.)

4 Likes