Hiding JUST ONE image button (not the screen)?

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
ChaiLatte
Newbie
Posts: 5
Joined: Thu Jan 27, 2022 2:01 pm
Contact:

Hiding JUST ONE image button (not the screen)?

#1 Post by ChaiLatte »

Hi. So I know you can hide an entire screen but with the way some other code for my game works I need to keep the screen up at all times. However I do need to be able to hide and unhide imagebuttons on said screen frequently throughout the game (they are clickable characters that exist in a location and on each location I need to swap out which characters are there as you click to interact with them).

Any way I can do this? I was looking around and couldn't find any evidence of this being possible.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Hiding JUST ONE image button (not the screen)?

#2 Post by rayminator »

this one way

Code: Select all

if button_on == False:
        textbutton _("test") action [SetVariable("button_on", True), Show("test")]
    else:
        None  or pass

ChaiLatte
Newbie
Posts: 5
Joined: Thu Jan 27, 2022 2:01 pm
Contact:

Re: Hiding JUST ONE image button (not the screen)?

#3 Post by ChaiLatte »

rayminator wrote: Thu Jan 27, 2022 10:44 pm this one way

Code: Select all

if button_on == False:
        textbutton _("test") action [SetVariable("button_on", True), Show("test")]
    else:
        None  or pass
Hi there. Thanks for your help.
How would I co-opt this for image buttons? I declared my button like so:

Code: Select all

screen overlaycharacters():
            imagebutton: #create clickable character on screen
                xpos 0.5
                ypos 0.28
                idle "bun_map_auto.png" #image non hovered
                hover "bun_map_hover.png" #image hovered
                action Jump("chatwithbun") #jump to label with dialogue for scene

I'm assuming I can't just have two actions for one button, can I ?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Hiding JUST ONE image button (not the screen)?

#4 Post by Per K Grok »

ChaiLatte wrote: Fri Jan 28, 2022 1:12 am
rayminator wrote: Thu Jan 27, 2022 10:44 pm this one way

Code: Select all

if button_on == False:
        textbutton _("test") action [SetVariable("button_on", True), Show("test")]
    else:
        None  or pass
Hi there. Thanks for your help.
How would I co-opt this for image buttons? I declared my button like so:

Code: Select all



I'm assuming I can't just have two actions for one button, can I ?
Yes you can have two (or more) actions to one button [which is in rayminator's example, SetVariable and Show ]
You could use that example like this

Code: Select all


screen overlaycharacters():
  if button_on == False:
        imagebutton: #create clickable character on screen
            xpos 0.5
            ypos 0.28
            idle "bun_map_auto.png" #image non hovered
            hover "bun_map_hover.png" #image hovered
            action [SetVariable("button_on", True), Jump("chatwithbun") ]  #jump to label with dialogue for scene
            

ChaiLatte
Newbie
Posts: 5
Joined: Thu Jan 27, 2022 2:01 pm
Contact:

Re: Hiding JUST ONE image button (not the screen)?

#5 Post by ChaiLatte »

It worked-- thanks so much both of you :D

ChaiLatte
Newbie
Posts: 5
Joined: Thu Jan 27, 2022 2:01 pm
Contact:

Re: Hiding JUST ONE image button (not the screen)?

#6 Post by ChaiLatte »

Actually... I forgot something (sorry for double post). Is there a way to do this in an area besides the creation of the imagebutton itself? I need to hide the characters when you switch maps as well, so you can come back and click them later.

edit: NEVERMIND AGAIN! I found out that if I have multiple screens it works just fine <3

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Sugar_and_rice