[Solved] Imagebutton ATL Hover/Unhover Animation

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
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

[Solved] Imagebutton ATL Hover/Unhover Animation

#1 Post by papiersam »

Very silly question that I'm sure has a concise answer somewhere that I can't find, but:

How do you use an ATL image as an argument for an imagebutton?

I tried it like this:

Code: Select all

image test:
    "newgame.png"
    0.5
    "newgameo.png" with Dissolve(0.75, alpha=True)

screen main_menu():
    tag menu
    
    hbox:
        align 0.5, 0.8
        imagebutton idle "newgame.png" hover test action Start()  
But that just throws a "test undefined" error.

I did an outdated workaround like this:

Code: Select all

define nwg = anim.TransitionAnimation("newgame.png", 1.0, Dissolve(0.5, alpha=True), 
                "newgameo.png", 2.0, Dissolve(0.5, alpha=True))
screen main_menu():

    hbox:
        align 0.5, 0.8
        imagebutton idle "newgame.png" hover nwg action Start() 
However, it's deprecated and it doesn't reset the animation every time I unhover and re-hover. So how would I accomplish this?

Thanks.

Postscript: and is there an 'unhover' animation option/workaround?
Last edited by papiersam on Tue Dec 13, 2016 7:08 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Imagebutton ATL Hover/Unhover Animation

#2 Post by Ocelot »

Did you try imagebutton idle "newgame.png" hover "test"?

IIRC it will try to find defined image with that name before trying to load it.
< < insert Rick Cook quote here > >

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Imagebutton ATL Hover/Unhover Animation

#3 Post by papiersam »

Did you try imagebutton idle "newgame.png" hover "test"?

IIRC it will try to find defined image with that name before trying to load it.
Right you are, thanks for that.

Still, the animation doesn't restart after I unhover and rehover. I don't mean to use repeat, I just want the animation to work every time I hover over the button.

Also, still wondering about unhover animation possibilities.

Thanks!

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Imagebutton ATL Hover/Unhover Animation

#4 Post by xavimat »

r_sami wrote:still wondering about unhover animation possibilities.
Well, your request seems interesting. I've tried with no success with imagebuttons, but I think this is your desired effect using buttons:

Code: Select all

screen test():
        button:
            xysize (300, 50)
            add "img_button"
            action ToggleVariable("var", True, False)

image img_button:

    Solid("#440", xysize=(300,50))

    on idle:
        Solid("#440", xysize=(300,50)) with Dissolve(0.75, alpha=True)
    on hover:
        Solid("#880", xysize=(300,50)) with Dissolve(0.75, alpha=True)
    on selected_idle:
        Solid("#044", xysize=(300,50)) with Dissolve(0.75, alpha=True)
    on selected_hover:
        Solid("#088", xysize=(300,50)) with Dissolve(0.75, alpha=True)

label start:
    $ var = False
    show screen test
    pause
You'll change the Solid() with "yourimage.png".
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Imagebutton ATL Hover/Unhover Animation

#5 Post by papiersam »

Yup, that did the trick (I used to use some bulkier version of that for imagebutton animation, good to see a better use for it). Just to note, to replace the Solid() with my image, I had to set the background to None to remove any...well, background:

Code: Select all

        button:
            add "img_button"
            action ToggleVariable("var", True, False)
            clicked Notify("Note")
            background None
Couldn't get a variant to work with imagebutton, but this'll do just fine (it also runs the animation upon calling the screen, but I'll figure that out later).

Thank you for your help.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: [Solved] Imagebutton ATL Hover/Unhover Animation

#6 Post by xavimat »

You're welcome :)

Btw, can you have "clicked" and "action" in the same button? I thought clicked was obsolete.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: [Solved] Imagebutton ATL Hover/Unhover Animation

#7 Post by papiersam »

Btw, can you have "clicked" and "action" in the same button?
It seems to work properly. I figured that was the use of clicked: if action was taken, I use clicked instead.

Update: Oh! When you put ToggleVariable("nvar", True, False), you meant that as a stand in action! I have no idea why I assumed that was there to toggle the image state.

Well, that changes things.

Still, clicked seems to work correctly. In fact, after testing, it has apparent priority over action; the clicked argument will be executed, while the action will be ignored. It's been removed from the docs as far as I can tell, so it should be at least deprecated.

Weird.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: [Solved] Imagebutton ATL Hover/Unhover Animation

#8 Post by xavimat »

Yes, it's weird that clicked is working (I presume because of backwards compatibility) but has also priority over "action".
I've never used clicked. In action you can use a list of actions to trigger more than one action in one click.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: No registered users