Hotspots: How to remove button image when not on a hotspot?

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
AnnieDB
Regular
Posts: 40
Joined: Tue Dec 01, 2015 3:24 pm
Location: Seattle
Contact:

Hotspots: How to remove button image when not on a hotspot?

#1 Post by AnnieDB » Sat Nov 30, 2019 4:32 pm

I'm working on a very hotspot-heavy project (basically, where vbox work would kind of be impossible) and my biggest problem is that an empty button hangs around when one of the hotspots is not selected. I'm sure there's a proper way to do this with a combo of "unhover" and "Hide," but all my searches have led to a lot of archaic info and elements that contradict my current setup. I'm hoping I don't have to redo all of them (cue silent screaming face) but if I have a handle on what I'm doing, I'm good with that.

Any help would be hugely appreciated!

IMAGE!
Image

CODE!

Code: Select all

#### Character Select ####

    screen port_int_imagemap:
        default tt = Tooltip("")

        default x = 500 # add three lines to get mouse position
        default y = 400
        $ x,y = renpy.get_mouse_pos()

        imagemap:
            ground "images/backgrounds/WaitingRoom_Base_Ground_Frame.png"
            hover "images/backgrounds/WaitingRoom_Base_Hover_Frame.png"

            hotspot (1235, 10, 170, 330) clicked Return("Thief") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Confident Thief") unhovered tt.Action("")
            hotspot (875, 375, 445, 690) clicked Return("Traveler") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Weary Traveler") unhovered tt.Action("")
            hotspot (490, 175, 230, 345) clicked Return("Scientist") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Scared Scientist") unhovered tt.Action("")

        frame:
            pos(x, y) # this positions the frame at the mouse position - you can adjust by using x + 10 or whatever to fine tune.
            xsize 160 # just made the width 50 so you could see how the frame being small makes the text wrap. Add more styles to the frame as necessary
            text tt.value # style text as necessary

User avatar
Kia
Miko-Class Veteran
Posts: 908
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: Hotspots: How to remove button image when not on a hotspot?

#2 Post by Kia » Sun Dec 01, 2019 3:23 am

May I suggest using "imagebutton" or "button" instead of "imagemap"? it will make your work much easier and you can give the buttons absolute positions the same way you position the hotspots

User avatar
Per K Grok
Miko-Class Veteran
Posts: 673
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
Projects: Defenders of Adacan Part 2
itch: per-k-grok
Location: Sverige
Contact:

Re: Hotspots: How to remove button image when not on a hotspot?

#3 Post by Per K Grok » Sun Dec 01, 2019 4:26 am

AnnieDB wrote:
Sat Nov 30, 2019 4:32 pm
I'm working on a very hotspot-heavy project (basically, where vbox work would kind of be impossible) and my biggest problem is that an empty button hangs around when one of the hotspots is not selected. I'm sure there's a proper way to do this with a combo of "unhover" and "Hide," but all my searches have led to a lot of archaic info and elements that contradict my current setup. I'm hoping I don't have to redo all of them (cue silent screaming face) but if I have a handle on what I'm doing, I'm good with that.

Any help would be hugely appreciated!

IMAGE!
Image

CODE!

Code: Select all

#### Character Select ####

    screen port_int_imagemap:
        default tt = Tooltip("")

        default x = 500 # add three lines to get mouse position
        default y = 400
        $ x,y = renpy.get_mouse_pos()

        imagemap:
            ground "images/backgrounds/WaitingRoom_Base_Ground_Frame.png"
            hover "images/backgrounds/WaitingRoom_Base_Hover_Frame.png"

            hotspot (1235, 10, 170, 330) clicked Return("Thief") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Confident Thief") unhovered tt.Action("")
            hotspot (875, 375, 445, 690) clicked Return("Traveler") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Weary Traveler") unhovered tt.Action("")
            hotspot (490, 175, 230, 345) clicked Return("Scientist") hover_sound "audio/sounds/_menu_over2.wav" activate_sound "audio/sounds/_menu_over.wav" hovered tt.Action("Scared Scientist") unhovered tt.Action("")

        frame:
            pos(x, y) # this positions the frame at the mouse position - you can adjust by using x + 10 or whatever to fine tune.
            xsize 160 # just made the width 50 so you could see how the frame being small makes the text wrap. Add more styles to the frame as necessary
            text tt.value # style text as necessary


If I understand this correctly the "button" is the frame-element last in the screen code, that is to be background to the tooltip.
If that is so, you could perhaps fix the problem by having the frame not showing when the tooltip don't have any text.

Code: Select all

if tt.value!="":
    frame:
        - etc-

User avatar
AnnieDB
Regular
Posts: 40
Joined: Tue Dec 01, 2015 3:24 pm
Location: Seattle
Contact:

Re: Hotspots: How to remove button image when not on a hotspot?

#4 Post by AnnieDB » Sun Dec 01, 2019 5:13 pm

HOLY YES Per I think that did it. I have been scratching around for something exactly like that and you handed me a solution. THANK YOU! :D

Post Reply

Who is online

Users browsing this forum: Imperf3kt