Unresponsive image buttons [SOLVED]

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
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Unresponsive image buttons [SOLVED]

#1 Post by Hikari_Kaitou »

Hello everyone, I'm new here and new to RenPy and I'm having kind of a strange problem. I suddenly can't get my image buttons to function. The hover states don't work and they don't perform the action I've programmed them to. There are no error reports, it simply doesn't work. I followed a video tutorial on youtube (https://www.youtube.com/watch?v=BJ3pqhQf2Rw) to the letter and it just does nothing. I realize that most of my actions say "Null", that's not the issue; the issue is that the hover version of the image doesn't appear and the jump doesn't work. Is this a matter of RenPy 8.1 working differently from older versions or am I missing something here?
Snipaste_2023-09-18_20-59-39.png
Last edited by Hikari_Kaitou on Wed Sep 20, 2023 10:01 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Unresponsive image buttons

#2 Post by Ocelot »

First two buttons might as well be not present. Third ove will be drawn over them and prevent them from ever working.

Third button will not receive any hover/unhover event since it lacks a proper on click Action.

As a bonus, you should not use hover/unhover actions to show tooltips (as it is unreliable, there are ways to get a hovered event without then triggering unhovered and vice versa) you should use tooltip property for that.
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Unresponsive image buttons

#3 Post by Imperf3kt »

In addition to the above, your indentation is not right, you are using 8 spaces, but you should be using 4

Here's an example of one way to use imagebuttons

Code: Select all

screen myScreen():
    modal True
    fixed:
        spacing 10

        imagebutton:
            auto "gui/myimage_1_%s.png"
            focus_mask True
            hovered <hovered action>
            unhovered <unhovered action>
            action NullAction()

        imagebutton:
            auto "gui/myimage_2_%s.png"
            focus_mask True
            hovered <hovered action>
            unhovered <unhovered action>
            action NullAction()

        imagebutton:
            auto "gui/myimage_3_%s.png"
            focus_mask True
            hovered <hovered action>
            unhovered <unhovered action>
            action NullAction()
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#4 Post by Hikari_Kaitou »

Ocelot wrote: Tue Sep 19, 2023 12:39 am First two buttons might as well be not present. Third ove will be drawn over them and prevent them from ever working.
I see, so how do I fix that?

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#5 Post by Hikari_Kaitou »

Imperf3kt wrote: Tue Sep 19, 2023 3:57 am In addition to the above, your indentation is not right, you are using 8 spaces, but you should be using 4
Does incorrect spacing prevent the code from functioning?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Unresponsive image buttons

#6 Post by Ocelot »

Hikari_Kaitou wrote: Tue Sep 19, 2023 11:07 am
Ocelot wrote: Tue Sep 19, 2023 12:39 am First two buttons might as well be not present. Third ove will be drawn over them and prevent them from ever working.
I see, so how do I fix that?
Depending on what you need, wrap them in hbox/vbox to lay them out horisontally/vertically or just provide them their positions with xpos/ypos or xalign/yalign
< < insert Rick Cook quote here > >

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#7 Post by Hikari_Kaitou »

Ocelot wrote: Tue Sep 19, 2023 11:17 am
Hikari_Kaitou wrote: Tue Sep 19, 2023 11:07 am
Ocelot wrote: Tue Sep 19, 2023 12:39 am First two buttons might as well be not present. Third ove will be drawn over them and prevent them from ever working.
I see, so how do I fix that?
Depending on what you need, wrap them in hbox/vbox to lay them out horisontally/vertically or just provide them their positions with xpos/ypos or xalign/yalign
Ok, I tried a different approach. Now the action that's supposed to happen does function, but it still doesn't show the idle or hover images. I still don't get an error message.

Code: Select all

screen waterfall_nav():
    imagemap:
        ground "forest 3 by brgfx_idle"

        fixed:
            spacing 10

            imagebutton:
                xpos 1562
                ypos 961
                idle "forest 3 by brgfx barley_idle"
                hover "forest_3_by_brgfx_barley_hover"
                action Jump("barley")

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Unresponsive image buttons

#8 Post by Imperf3kt »

Hikari_Kaitou wrote: Tue Sep 19, 2023 11:11 am
Imperf3kt wrote: Tue Sep 19, 2023 3:57 am In addition to the above, your indentation is not right, you are using 8 spaces, but you should be using 4
Does incorrect spacing prevent the code from functioning?
That depends.
https://www.renpy.org/doc/html/language ... and-blocks
Indentation is very important to Ren'Py, and cause syntax or logical errors when it's incorrect.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#9 Post by Hikari_Kaitou »

I'm not getting an error message, so hopefully that means the spacing is ok?

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#10 Post by Hikari_Kaitou »

Every time I create a second button, it overwrites the first button's function. I don't understand. I've already created four imagebuttons successfully on a different screen and they work just fine. These new imagebuttons look the same coding-wise but they don't work...

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

Re: Unresponsive image buttons

#11 Post by Alex »

Hikari_Kaitou wrote: Tue Sep 19, 2023 4:34 pm Every time I create a second button, it overwrites the first button's function. ...
What's the size of your imagebuttons - any chance that they are overlap each other (as Ocelot pointed)?
How do you positioning them (are they inside a v/hbox, grid or have individual coordinates)?

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#12 Post by Hikari_Kaitou »

Alex wrote: Wed Sep 20, 2023 2:20 pm
Hikari_Kaitou wrote: Tue Sep 19, 2023 4:34 pm Every time I create a second button, it overwrites the first button's function. ...
What's the size of your imagebuttons - any chance that they are overlap each other (as Ocelot pointed)?
How do you positioning them (are they inside a v/hbox, grid or have individual coordinates)?
Here's my code

Code: Select all

screen waterfall_nav():
    imagemap:
        ground "forest 3 by brgfx_idle"

        imagebutton:
            xpos 1562
            ypos 961
            hover "forest_barley_hover"
            idle "forest_barley_idle"
            action Jump("barley")

        imagebutton:
            xpos 242
            ypos 658
            hover "forest_muscat_hover"
            idle "forest_muscat_idle"
            action Jump("muscat")

        imagebutton:
            xpos 524
            ypos 954
            hover "forest_chamomile_hover"
            idle "forest_chamomile_idle"
            action Jump("chamomile")
It's formatted exactly like my other screen, which works perfectly, and yet this one doesn't do what it's supposed to :(

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

Re: Unresponsive image buttons

#13 Post by Alex »

Hikari_Kaitou wrote: Wed Sep 20, 2023 2:55 pm ...
So, what about size of those 'forest' images?

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#14 Post by Hikari_Kaitou »

Alex wrote: Wed Sep 20, 2023 4:18 pm
Hikari_Kaitou wrote: Wed Sep 20, 2023 2:55 pm ...
So, what about size of those 'forest' images?
All my images are 1200 x 1080. The hovered and idle images are completely transparent, except for the affected areas.

User avatar
Hikari_Kaitou
Newbie
Posts: 12
Joined: Mon Sep 18, 2023 9:14 pm
Tumblr: hikari-kaitou
Contact:

Re: Unresponsive image buttons

#15 Post by Hikari_Kaitou »

Someone helped me figure out the problem. My hover and idle images didn't need all that transparent space. After cropping the images down, they fit on the screen properly. Thank you to everyone who advised me!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]