-
Notifications
You must be signed in to change notification settings - Fork 10
Description
What is the problem this request aims to solve?
The current Flex Panel documentation makes it easy to assume that layerElements are “static” once created, because editing the struct returned by flexpanel_node_get_struct() does not update the live element.
As a result, users may believe the only way to change a Sprite/Text element at runtime is to rebuild nodes/panels (clone -> destroy -> recreate), especially for common tasks like tinting a sprite or updating text. This is both error-prone and discourages usage of Sprite/Text layerElements in UI layers.
Currently the only things I know of which suggest that elementId are able to be used in layer functions are these two small references.
(thank you endy and shdwcat in the kitchen discord for these suggestions)
How do you suggest we solve this problem?
Documentation improvements:
- Add a dedicated section under Flex Panels/UI Layers runtime docs titled something like:
- “Editing Sprite/Text/Object layerElements at runtime (using elementId)”
- Provide a minimal example showing:
- Fetch a flex node struct
- Read layerElements[n].elementId
- Call layer_sprite_blend() / layer_text_text() using that handle
Example:
var _root = layer_get_flexpanel_node("UI_Layer");
var _panel = flexpanel_node_get_child(_root, "FlexPanel");
var _struct = flexpanel_node_get_struct(_panel);
// Assume layerElements[0] is a Sprite element
var _sprite_element_id = _struct.layerElements[0].elementId;
layer_sprite_blend(_sprite_element_id, c_red);
// Assume layerElements[1] is a Text element
var _text_element_id = _struct.layerElements[1].elementId;
layer_text_text(_text_element_id, "HP: 50");- Explicitly warn users that:
- Editing the returned struct does not mutate the live elements.
- The correct approach is to use elementId + layer element APIs.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status