[SOLVED] How to prevent imagebutton to be clicked when an image is in front of it?

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
GeeSeki
Regular
Posts: 112
Joined: Sat Dec 17, 2016 3:39 am
Projects: A Town Uncovered
itch: geeseki
Contact:

[SOLVED] How to prevent imagebutton to be clicked when an image is in front of it?

#1 Post by GeeSeki »

Hi, how do I prevent an imagebutton to activate if an image is in front of it on screen? At the moment, I can click on the image and it'll still trigger the imagebutton when I don't want it to.

Thanks
Last edited by GeeSeki on Thu Jan 13, 2022 8:52 pm, edited 2 times in total.

User avatar
GeeSeki
Regular
Posts: 112
Joined: Sat Dec 17, 2016 3:39 am
Projects: A Town Uncovered
itch: geeseki
Contact:

Re: How to prevent imagebutton to be clicked when an image is in front of it?

#2 Post by GeeSeki »

I found a work-around.

I have a the 'black' background as a btn at alpha 0.01 so that the player can trigger an action by pressing anywhere on the screen as well as not have it be visible.

I replaced the image with an image btn version of it and have the action show the same screen that it's on so it appears as if nothing has happened and it doesn't trigger the black image button

If there's a more effective workaround, let me (or others) know but this works.

Code: Select all

imagebutton auto "btn black_%s" xpos 0 ypos 0 focus_mask True action [
    Play("sound","audio/sfx/ReportPadClose2.ogg"),
    SetVariable("report_is_pressed",0),
    Hide("scr_reportpad_house", transition=Dissolve(0.05)),
    Show("scr_reportpad_house_close")]
    
imagebutton auto "btn reportpad_house_prevent_%s" xpos 0 ypos 0 focus_mask True action Show("scr_reportpad_house")
# add "images/border/img_reportpad.png" xpos 0 ypos 300

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], piinkpuddiin