Showing an Image with Variable Position on Imagebutton Hover

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
Treladon
Regular
Posts: 40
Joined: Sat Dec 31, 2016 3:20 pm
Projects: ToMaG, Feinted Game
Organization: Kuehler-Corrada Productions
Deviantart: Journie
Contact:

Showing an Image with Variable Position on Imagebutton Hover

#1 Post by Treladon » Sat Mar 11, 2017 3:02 pm

Hi,

Is it possible to show an extra image in another area of the screen when a player is hovered over a button?
For example, I have this navigation menu:

Code: Select all

    screen navig:
        imagebutton auto "navig button left %s.png" xpos .4 ypos 415 focus_mask True action dleft hover_sound "button hover.wav"
        imagebutton auto "navig button right %s.png" xpos .5 ypos 415 focus_mask True action dright hover_sound "button hover.wav"
        imagebutton auto "navig button back %s.png" xpos .45 ypos 470 focus_mask True action dback hover_sound "button hover.wav"
        imagebutton auto "navig button up %s.png" xpos .45 ypos 360 focus_mask True action dup hover_sound "button hover.wav"
as well as a minimap in the corner of the screen that shows a dot at the player's position on the map.
Is it possible to show an arrow on the minimap when the player hovers over a button? For instance, if you hover over "navig button left.png", it will also show a tiny arrow to the left of the player's dot on the map to show which direction on the map that action will take them down. I thought about doing an imagemap instead, but the minimap arrow needs to be able to change position depending on the player's location on the minimap.
This was my latest attempt for "navig button left":

Code: Select all

        imagebutton:
            xpos .4 ypos 415
            idle "navig button left idle.png"
            hover "navig button left hover.png" add "map arrow left.png" at Position(xpos = (dot.xpos)*1066 - 7, ypos=(dot.ypos)) #a few pixels left of the player's dot on the minimap.
            insensitive "navig button left insensitive.png"
            action dleft
            hover_sound "button hover.wav"
The error it gives is either that "add" is not a keyword argument for imagebuttons or that "xpos" appears more than once.
Any help would be appreciated. Thank you!
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Showing an Image with Variable Position on Imagebutton H

#2 Post by SuperbowserX » Sat Mar 11, 2017 3:09 pm

I apologize in advance if I'm wrong (I'm not sure if I fully understand aha but that's probably because I'm half-asleep right now), but I think you may be looking for the ability to implement multiple actions.

viewtopic.php?f=8&t=37185

Make one of those actions showing a screen that shows the image what you want.

User avatar
Treladon
Regular
Posts: 40
Joined: Sat Dec 31, 2016 3:20 pm
Projects: ToMaG, Feinted Game
Organization: Kuehler-Corrada Productions
Deviantart: Journie
Contact:

Re: Showing an Image with Variable Position on Imagebutton H

#3 Post by Treladon » Sat Mar 11, 2017 4:44 pm

I apologize in advance if I'm wrong (I'm not sure if I fully understand aha but that's probably because I'm half-asleep right now), but I think you may be looking for the ability to implement multiple actions.

viewtopic.php?f=8&t=37185

Make one of those actions showing a screen that shows the image what you want.
Thanks, but that's not exactly what I mean. I don't want the action to contain multiple things but, rather, the images shown for the "hover" button. I would simply make one image out of the ones I want to appear, but the problem is that I want the arrow that appears on the minimap to depend on the dot's location. Here's a screenshot of what I currently have:
screenshot.PNG
I want the hover action to make a small arrow on the minimap appear just next to the dot, but the dot changes position every time you go down a road.
WIP: The Tasks of Messengers and Guardians - Progress Page Here!

User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Re: Showing an Image with Variable Position on Imagebutton H

#4 Post by Smaymay » Sat Mar 11, 2017 5:04 pm

I could be wrong but maybe a tooltip image could be what you're looking for?
https://www.renpy.org/doc/html/screen_a ... l#tooltips

I used a tooltip to make an image appear when I hover on an imagebutton.

Code: Select all

imagebutton:
        idle "images/waldo_small.png"
        xanchor 0.5 yanchor 0.5
        xpos 1216 ypos 673 focus_mask True
        hovered [Play ("Soundeffect", "audio/soundeffects/dialogue_start.ogg"),
        Show("gui_tooltip", tt_source="gui/speech_r.png", tt_xpos=843, tt_ypos=339)]
        unhovered [Hide("gui_tooltip")]
        action [Hide("gui_tooltip"), Jump("waldo_dialogue")]

Code: Select all

screen gui_tooltip:
    add tt_source xpos tt_xpos ypos tt_ypos

Post Reply

Who is online

Users browsing this forum: enaielei