How to hide imagebuttons if click outside of button area?

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
DarkCookie
Newbie
Posts: 13
Joined: Sat Jul 16, 2016 8:46 am
Contact:

How to hide imagebuttons if click outside of button area?

#1 Post by DarkCookie » Mon Aug 15, 2016 2:22 pm

Ok so let's say I have a room with multiple objects in it such as a door (see code below).

If I click on a door and an imagebutton comes up with "Would you like to go outside?" on it, I want to be able to click off screen/around the button and hide/cancel the option.

Is there a simple way of doing this? I'm thinking I might have to create a transparent imagebutton the size of my screen behind the door button that would "hide" it...

Code: Select all

###ROOM###
    screen room:
        add "room.jpg"
        imagebutton:
            idle "door.png"
            hover "door2.png"
            action Show ("door_options")
            xpos 44
            ypos 352
###DOOR_OPTION###
    screen door_options:
        imagebutton:
            idle "button.png"
            hover "button2.png"
            action [Hide ("telescope_options"),Hide ("room"), Jump ("outside")]
            xpos 300
            ypos 600

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

Re: How to hide imagebuttons if click outside of button area

#2 Post by Alex » Mon Aug 15, 2016 2:31 pm

You thought right - in screen door_options make a whole screen-size imagebutton that will hide this screen, and place the other button over it.

User avatar
DarkCookie
Newbie
Posts: 13
Joined: Sat Jul 16, 2016 8:46 am
Contact:

Re: How to hide imagebuttons if click outside of button area

#3 Post by DarkCookie » Mon Aug 15, 2016 5:54 pm

Alex wrote:You thought right - in screen door_options make a whole screen-size imagebutton that will hide this screen, and place the other button over it.

Tried it and it works surprisingly well.. I was expecting something buggy but it's smooth.

Thanks

Post Reply

Who is online

Users browsing this forum: No registered users