Hide / unhide imagebutton.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
nikraria
Newbie
Posts: 11
Joined: Fri Aug 29, 2014 3:53 pm
Contact:

Hide / unhide imagebutton.

#1 Post by nikraria »

First thing my apologizes for me English use, is very limitated.

Could someone tell me how I can hide a imagebuton?

I have a simple system for search with mouse objects in the screen.
I use a great code from Alex user here :http://lemmasoft.renai.us/forums/viewto ... f=8&t=6460

But I have no a textbutton, in my case I have a imagebutton. When I call screen for search the picture for the button still there, and I want to know if I can hide the button in someway.

Hope you understand me well, if you don´t I'll try to explain me better with clarifications.

Thank you very much for this awesome page, I never could finish my last project without help from here.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Hide / unhide imagebutton.

#2 Post by Alex »

This was an old style of showing things on screen (overlay functions). This was working like

Code: Select all

init:
    $ the_thing_button_do = None
    $ show_button = False
    python:
        def my_button():
            if show_button:
                ui.textbutton("?", clicked=the_thing_button_do, xalign=.95, yalign=.05)
            
        config.overlay_functions.append(my_button)
        

# The game starts here.
label start:

    scene black
    "There is no button..."
    $ show_button = True
    "Here it is!"
    $ the_thing_button_do = None
    "The button is disabled"
    $ the_thing_button_do = (ui.jumps("some_label"))
    "Now, it leads to \"some_label\""
    $ the_thing_button_do = None
    "Disabled again"
    $ show_button = False
    "... and disappeared..."
    jump start
    
label some_label:
    $ the_thing_button_do = None
    "This is some_label"
    "And button disabled (if not, you could click it and see \"some_label\" once again)"
    $ show_button = False
    jump start
In modern Ren'Py you should use screens for that

Code: Select all

screen my_button:
    imagebutton:
        xalign 0.95 yalign 0.05
        idle "idle_img.png"
        hover "hover_img.png"
        insensitive "insensitive_img.png"
        action x

label start:
    scene black
    "There is no button..."
    show screen my_button(x=None)
    "Here it is!"
    "The button is disabled"
    show screen my_button(x=Jump("some_label"))
    "Now, it leads to \"some_label\""
    show screen my_button(x=None)
    "Disabled again"
    hide screen my_button
    "... and disappeared..."
    jump start
    
label some_label:
    show screen my_button(x=None)
    "This is some_label"
    "And button disabled (if not, you could click it and see \"some_label\" once again)"
    hide screen my_button
    jump start

http://www.renpy.org/doc/html/index.html
http://www.renpy.org/doc/html/screens.html
http://www.renpy.org/doc/html/screens.html#imagebutton

User avatar
nikraria
Newbie
Posts: 11
Joined: Fri Aug 29, 2014 3:53 pm
Contact:

Re: Hide / unhide imagebutton.

#3 Post by nikraria »

Work perfect!!
Thank you very much gentleman!!

Post Reply

Who is online

Users browsing this forum: No registered users