Я попытался создать пользовательское свойство под названием «глубина», похожее на y sort, где чем выше значение глубины, тем больше «в front" изображение рисуется.
До сих пор я использовал GDExtension и следил за тем, как y sort собирает дочерние узлы и сортирует узлы как таковые:
Код: Выделить всё
void GDExample::sort_children_by_depth()
{
// get top most node (sort_node) whose children are to be sorted
GDExample *sort_node = this;
GDExample *parent_node = (GDExample *)sort_node->get_parent();
while (parent_node && parent_node->get_class() == this->get_class())
{
sort_node = parent_node;
parent_node = (GDExample *)parent_node->get_parent();
}
// get children of `sort_node` from every level
int children_count = 1; // 1 since including `sort_node`
_collect_depth_children(sort_node, nullptr, children_count);
GDExample **child_items = (GDExample **)alloca((children_count) * sizeof(GDExample *));
child_items[0]=sort_node;
// to store all children into child_items
children_count = 1;
_collect_depth_children(sort_node, child_items, children_count);
// sort all nodes based on their depth
SortArray sorter;
sorter.sort(child_items, children_count);
// get the index of `sort_node`
int sort_node_index=-1;
for(int i=0; ihow do I replace the below segment by flattening the items into a single z index?
//
for(int i=0; iset_z_index(i - sort_node_index);
}
в пределах одного и того же индекса z, но я понятия не имею, как реализовать это в моем собственном коде .
Итак, как мне управлять порядком элементов, отображаемых в одном индексе? (или любой другой подход с аналогичным эффектом?)
Изменить: Я пробовал использовать Canvas_item_set_draw_index, однако это сортируется только между братьями и сестрами, тогда как мне нужна сортировка между все уровни узла
Подробнее здесь: https://stackoverflow.com/questions/784 ... me-z-index
Мобильная версия