Apply transforms on hover/unhover for ImageButton

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
inoix
Newbie
Posts: 3
Joined: Wed Jul 12, 2023 7:06 am
Contact:

Apply transforms on hover/unhover for ImageButton

#1 Post by inoix »

I have a quite simple image in a scene:

Code: Select all

screen navigation(show_buttons=True):

    if main_menu:
        on "replace" action Hide("navigation")
        showif show_buttons:
            imagebutton auto "button_menu newgame %s" action Start() style "button_newgame_style"
            ...
    else: ...
How do I apply a hover, unhover transform like:

Code: Select all

transform button_menu_hover:
    zoom 1.0
    linear 1.0 zoom 2.0
transform button_menu_unhover:
    zoom 2.0
    linear 1.0 zoom 1.0
I could paste it in image definitions:

Code: Select all

image button_menu newgame idle:
    ...
    zoom 2.0
    linear 2.0 zoom 1.0
image button_menu newgame hover:
    ...
    zoom 1.0
    linear 1.0 zoom 2.0
or in atl transform:

Code: Select all

transfrom button_menu_transfrom:
	on hover:
		zoom 1.0
		linear 1.0 zoom 2.0
	on idle:
		zoom 2.0
		linear 1.0 zoom 1.0
But then it would apply the hover->unhover transition when scene starts, which is not what I want. And there is no "on unhover" to use instead of just "on idle", so I am quite confused :?
There is also "on show" in atl, but I do not see a good way to use it.

I'd appreciate if anyone knows a good way of doing this.

inoix
Newbie
Posts: 3
Joined: Wed Jul 12, 2023 7:06 am
Contact:

Re: Apply transforms on hover/unhover for ImageButton

#2 Post by inoix »

After some digging I found that I was actually very close:
You can actually use something like that

Code: Select all

transfrom button_menu_transfrom:
	on hover:
		zoom 1.0
		linear 1.0 zoom 2.0
	on idle:
		linear 1.0 zoom 1.0
without defining zoom at the start of "on idle". Sorry for everyone who got here to answer it!

Post Reply

Who is online

Users browsing this forum: Google [Bot]