Based on this button implementation:
I want to make button implementation that behave like 2 sprite when pressed and not
And for implement this, then I have 1 node on .gui with not-pressed flipbook/animation or texture(?) in component, called “button_red”.
So, when it clicked, it will change to “button_red2”, but since I have no idea to return that hash into string because I get_texture from that node, then im doing this:
-- button.lua
function Button.new(context, node_name, type, handler)
…
if self.button_type == SPRITE_TYPE then
local texture = gui.get_flipbook(self.node)
self.texture = string.sub(tostring(texture), 8, #tostring(texture)-1)
self.next_texture = string.sub(tostring(texture), 8, #tostring(texture)-1).."2"
...
later, I call this string value on variable to change node
-- button.lua
function Button:press()
if self.button_type == SPRITE_TYPE then
gui.play_flipbook(self.node, self.next_texture)
...
Sorry for long explanation, maybe its bit weird grammar, but yeah, I have no idea in the first place to make polished button on GUI, then this is why im doing it.