using transform with hover?

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
jack_norton
Lemma-Class Veteran
Posts: 4085
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

using transform with hover?

#1 Post by jack_norton »

I thought about a nice effect to have on buttons using the new screen and ATL. What I wanted to make is quite simple: I have some buttons and wanted to zoom them in/out as the player hover the mouse over them.
However, I am not sure really how I could do this - I mean the imagebutton should call an action on the over? but that action can modify the transform of the imagebutton that called it?
I am a bit confused :D before ATL I managed to make some effect like moving buttons using classes, like for a RPG where staves would go up/down when hovering mouse on them:

Code: Select all

        class Staff(object):
            def __init__(self,id,x,y):
                self.x=x;self.y=y;self.id=id;self.ok=None
            def show(self):
                self.ok = True
                renpy.store.curid=self.id;renpy.store.tipT=Eld[self.id]
                renpy.sound.play("snd/e"+str(self.id+1)+".ogg")
                renpy.show("staff"+str(self.id), [FactorZoom(.7, .75, 0.6, opaque=False),Position(xalign=self.x,yalign=self.y)])
                renpy.restart_interaction()
            def hide(self):
                if self.ok:
                    renpy.show("staff"+str(self.id), [FactorZoom(.75, .7, 0.6, opaque=False),Position(xalign=self.x,yalign=self.y)])
                    renpy.store.curid=-1
                    self.ok = False
                    renpy.restart_interaction()
but I must admit that I wouldn't know how to reproduce that for example using the new screen/ATL system. If anyone can illuminate me (and maybe others) with an example would be welcome :mrgreen:
follow me on Image Image Image
computer games

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: using transform with hover?

#2 Post by PyTom »

If you put a button directly inside a transform, the various button-related events (on hover, on idle, on selected_hover, on selected_idle) will be delivered automatically.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4085
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: using transform with hover?

#3 Post by jack_norton »

Ahhh me=stupid. I didn't notice you added (or maybe there were already) the various events on the ATL :D thanks!
follow me on Image Image Image
computer games

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: using transform with hover?

#4 Post by SundownKid »

PyTom wrote:If you put a button directly inside a transform, the various button-related events (on hover, on idle, on selected_hover, on selected_idle) will be delivered automatically.
I still don't quite understand the specifics of this - how does one put an imagebutton inside a transform and then add it to a vbox or hbox? This could greatly assist me in the creation of my buttons.

Post Reply

Who is online

Users browsing this forum: No registered users