Creating an on-screen button can be found in the Cookbook (
Button Game Menu).
Just replace "textbutton" with "imagebutton". You can format it like...
Code: Select all
show_whatever_button = False
def whatever_button():
if show_whatever_button:
ui.hbox(xpos = 100, xalign=0, ypos = 100, yalign=0)
ui.imagebutton("idle.png", "hover.png", clicked=renpy.curried_call_in_new_context("label_to_jump_to"))
ui.close()
config.overlay_functions.append(whatever_button)
The above assumes that you'll want the button to appear at certain times and disappear at others, so you can toggle it using
$ show_whatever_button = True/False
Or you can actually add a button a little easier with the new screen language.
Code: Select all
screen whatever:
hbox xalign 0 yalign 0:
imagebutton auto "button_%s.png" action Jump('label_to_jump_to') pos (100,100)
## Here's an example of how to toggle the button to show or disappear.
label start:
show screen whatever
"Now you see it..."
hide screen whatever
"...And now you don't."
In the above example, you would need to make six images:
button_idle, button_hover, button_insensitive, button_selected_idle, button_selected_hover, button_selected_insensitive
Both methods do the same thing - show a button on the screen. However, if you plan for the button to go to a pre-defined Ren'py label (such as jump to the main menu, a game menu, or the confirm quit screen), then you'll want to use the first method so that the button disappears when you go to that screen.