Gooey error

I’m trying to use the Gooey extension to add nicer button and lists.

But I get this error:

views/title/title.gui_script:15: Animation 'button_normal' invalid for node 'play_button' (no animation set)
stack traceback:
[C]: in function 'play_flipbook'
/views/title/title.gui_script:15: in function 'refresh_fn'
gooey.internal.button:9: in function 'fn'
gooey.internal.core:110: in function 'refresh'
gooey.internal.button:31: in function <gooey.internal.button:16>
(tail call): ?
gooey.gooey:80: in function 'button'
/views/title/title.gui_script:41: in function </views/title/title.gui_script:40>

This is my code

local monarch = require "monarch.monarch"
local transitions = require "monarch.transitions.gui"
local gooey = require "gooey.gooey"
local rpg = require "gooey.themes.rpg.rpg"


local function update_button(button)
    if button.pressed_now then
    	gui.play_flipbook(button.node, hash("button_pressed"))
    elseif button.released_now then
    	gui.play_flipbook(button.node, hash("button_normal"))
    elseif not button.pressed and button.over_now then
    	gui.play_flipbook(button.node, hash("button_over"))
    elseif not button.pressed and button.out_now then
	    gui.play_flipbook(button.node, hash("button_normal"))
    end
end

local function on_pressed(button)
    print("pressed")
end



function init(self)
    msg.post(".", "acquire_input_focus")
    gooey.acquire_input()

    self.transition = transitions.create(gui.get_node("root"))
    	.show_in(transitions.slide_in_right, gui.EASING_OUTQUAD, 0.6, 0)
    	.show_out(transitions.slide_out_left, gui.EASING_INQUAD, 0.6, 0)
	    .back_in(transitions.slide_in_left, gui.EASING_OUTQUAD, 0.6, 0)
	    .back_out(transitions.slide_out_right, gui.EASING_INQUAD, 0.6, 0)

--update_button(gooey.button("menu_button").set_visible(false))
	
	
end

function on_input(self, action_id, action)
    rpg.button("play_button", action_id, action, on_pressed, update_button)

    if action_id == hash("click") and action.released then
	    if gui.pick_node(gui.get_node("play_button"), action.x, action.y) then
		    monarch.show(hash("menu"))
	    elseif gui.pick_node(gui.get_node("settings_button"), action.x, action.y) then
		    monarch.show(hash("settings_dialog"))
	    end
	
    end
end

function on_message(self, message_id, message, sender)
    self.transition.handle(message_id, message, sender)
end

“play_button” in the .gui file is just a box with a text inside it

Thanks!

This error:

indicates that there is no animation/image named “button_normal” in the atlas you use for the button graphics. You shouldn’t have to specify the update_button() function. The RPG theme takes care of it. Omit that last argument and it should work. Take a look at the example for the RPG theme: https://github.com/britzl/gooey/blob/master/example/rpg.gui_script

Ah so I need to add a texture to the button before? From the rpg theme?

You should use the existing templates for the different components that the RPG theme provides. Like this:

Add a gui template:

Select the RPG button template:

Give the button an id and change the label text:

Use it in your code:

local rpg = require "gooey.themes.rpg.rpg"

function on_input(self, action_id, action)
	rpg.button("mybutton", action_id, action, function()
		print("click")
	end)
end