Hello guys,
Am currently working on cloning the node. Using Collection factory am creating 25 different instances of nodes now when the user clicks on the particular node how I can handle that click event after I need to change that node to animation so please we have any chance to identify which node is clicked cloned node. (my plan is to use dynamic node and text otherwise i need to create 25 nodes with 25 text)
Thank you
local cloneTextField = gui.get_node(“TextField”)
cloneId = gui.clone(cloneTextField)
local new_textnode = gui.new_text_node(new_position, text)
You need to store the cloned nodes in a list and then iterate this list in on_input to check if a node has been pressed. Example:
function init(self)
self.nodes = {}
local original = gui.get_node("node_to_clone")
local clone = gui.clone(original)
table.insert(self.nodes, clone)
end
function on_input(self, action_id, action)
-- make sure to change "click" to the action in your input bindings
if action_id == hash("click") and action.pressed then
for _,node in ipairs(self.nodes) do
if gui.pick_node(node, action.x, action.y) then
print("clicked on node", node)
break
end
end
end
end