Coder Social home page Coder Social logo

Comments (7)

Kiamo2 avatar Kiamo2 commented on May 18, 2024

This raises an interesting question: How to differentiate between the CanvasItem's property 'z_index' and the same named Layers' property.
My proposal is to add a property with names 'layer_z_index' in Tiled to clarify that the according Layer property in Godot and not the Canvas property is targeted.
This way there would be no uncertainty left which Godot property is to be set.

With 'y_sort_enabled' there's seems to be no uncertainty cause if 'y_sort_enabled' is true on any layer it should be also set to true on the CanvasItem, otherwise there's a warning in Godot.

Would you agree to that proposal?

from yati.

pcloves avatar pcloves commented on May 18, 2024

This raises an interesting question: How to differentiate between the CanvasItem's property z_index and the same named Layers' property.

Based on my limited understanding of Godot and Tiled, It seems that the CanvasItem's property z_index should come from the "map Properties" in Tiled, rather than from "Layer Properties".

That means:
Tiled "map property" --> TileMap(CanvasItem's) property z_index
Tiled "Layer property" --> TileMap Layer's property z_index

If I am correct, there is no need to prefix "layer_" for the property z_index because it is possible to set a z_index in the "Map Properties" and another z_index in the "Layer Properties" without conflicting their names.

I hope I am expressing myself clearly because I am using Google Translator _

from yati.

Kiamo2 avatar Kiamo2 commented on May 18, 2024

Unfortunately it's not not as easy as you might think.
A Tiled map is not neccessarily equivalent to a Godot TileMap.
The Tiled map is equivalent to a complete Godot scene which might well be only a simple TileMap (in your case) but in various other cases not.
E.g. if 'use_tilemap_layers' is not set or the Tiled map additionally contains objects the base node in Godot will become a Node2D instead of a (Godot-)TileMap.
Thus Tiled's map properties as having no clear equivalent in Godot are currently not mapped at all.
It's probably possible to account for your case as "special case" and handle it like you proposed, but frankly I don't like special solutions as they are prone to unforeseeable side effects.
The proposal with the 'layer_' prefix would be unambigous and thus clean and additionally quite simple to implement.
Please note that in Godot the z_index property is fully qualified as 'layer_0/z_index' (or 'layer_1/z_index' and so on) which is at least a bit similar to 'layer_z_index'. (You can see that if you hover the mouse over the propery name).

from yati.

pcloves avatar pcloves commented on May 18, 2024

A Tiled map is not neccessarily equivalent to a Godot TileMap.
The Tiled map is equivalent to a complete Godot scene which might well be only a simple TileMap (in your case) but in various other cases not.

I did some tests, the results are just as you said.

I still have a question that haven't been clarified yet: When use_tilemap_layers is toggled, and there are some layers in Tiled, with each layer has a z_index property. Which z_index property should TileMap(CanvasItem's) ues?

It seems due to the use_tilemap_layers option, the Tilemap properties and the layer properties become complicated and ambiguous. We cannot intuitively determine whether the properties of the Tiled layer are mapped onto the TileMap or the layer of the TileMap.

from yati.

Kiamo2 avatar Kiamo2 commented on May 18, 2024

I've thought about all that and slept over it and I think now the best solution would be that if use_tilemap_layers is enabled the z_index property should go to the layer's z_index and if it's not enabled it's going to the canvas item (like now).
Probably the z_index on the canvas is not needed at all, if the TileMap has multiple layers, but I'm not sure.
Additionally to this heueristicaI determination I will add the possibility to be explicit by naming it either 'layer_z_index' or 'canvas_z_index'.
-> A simple 'z_index' without prefix will go either to the canvas item (if 'use_tilemap_layers' is off) or to the layer (if it's on).
If that's not wished it's possible to be explicit.

from yati.

pcloves avatar pcloves commented on May 18, 2024

Ah, this plan looks very sensible to me.

from yati.

Kiamo2 avatar Kiamo2 commented on May 18, 2024

Fixed in v1.2.5

I even implemented your proposal with the map attribute 'z_index'. If found it would be placed on the canvas item.
(But I don't know if you ever need that...)

from yati.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.