SOLVED: Composite for 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
thelastsecret
Regular
Posts: 122
Joined: Tue Mar 01, 2022 1:32 pm
Completed: The Last Secret
Projects: Sweet Science – The Girls from Silversee Castle
itch: thelastsecret
Discord: TheLastSecret #5266
Contact:

SOLVED: Composite for hover

#1 Post by thelastsecret »

I want to use a composite image as hover image. I thought that would be easy, so I used this code:

Code: Select all

init:
    image red_hover2=Composite(
        (960*0.8,1080*0.8),
        (0,0),im.FactorScale("red.png",0.8),
        (100,300),Text(_("Some text"))
        )

call screen choose_scenario

screen choose_scenario:
    hbox:
        yalign 0.3
        imagebutton:
            hover "red_hover2"
            idle "red_idle"
            xpos 100
            action Return("red")
(Cut short to the most essential part.)

However, it does not show any hover image (neither gives an error message).
What do I do wrong? Or is this just not possible?

It works, however, if I replace the image definition by:

Code: Select all

    image red_hover2 = im.FactorScale("red.png",0.8)
It's not the Text command, since after taking that out, it still does not show any hover image.
Last edited by thelastsecret on Tue Feb 20, 2024 8:09 am, edited 1 time in total.

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1012
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Composite for hover

#2 Post by m_from_space »

thelastsecret wrote: Tue Feb 20, 2024 12:49 am It's not the Text command, since after taking that out, it still does not show any hover image.
It's the image size calculation. Just calculate it yourself and put in the right values.

You also shouldn't use image manipulators, since they are ancient. Use Frame() or Transform() instead!

Code: Select all

image red_hover2 = Composite(
    (768, 864),
    (0, 0), Frame("red"),
    (100, 300), Text(_("Some text"))
)

User avatar
thelastsecret
Regular
Posts: 122
Joined: Tue Mar 01, 2022 1:32 pm
Completed: The Last Secret
Projects: Sweet Science – The Girls from Silversee Castle
itch: thelastsecret
Discord: TheLastSecret #5266
Contact:

Re: Composite for hover

#3 Post by thelastsecret »

Danke für die Hilfe und den Hinweis mit Frame/Transform!

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1012
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Composite for hover

#4 Post by m_from_space »

thelastsecret wrote: Tue Feb 20, 2024 8:08 am Danke für die Hilfe und den Hinweis mit Frame/Transform!
Gerne. :wink:

Post Reply

Who is online

Users browsing this forum: No registered users