Two animation questions

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
apocolocyntose
Newbie
Posts: 10
Joined: Mon Jun 06, 2016 2:34 am
Contact:

Two animation questions

#1 Post by apocolocyntose »

First, I have a button object, and when I hover over it, I would like two things to happen:

1. The button gradually expands to a wider size.
2. In parallel, the text child of the button switches from a shorter string to a longer string, preferably with a dissolve.

My problem is that when I apply an xsize or xzoom "on hover" animation to the button, the text is stretched along with the button background. I've worked out an alternate solution (two screens laid over the expanding button, containing only the text, dissolving in and out when the button is hovered/unhovered), but I could potentially need dozens of these buttons, and I feel I'm missing something here. What is the best way to separately animate the background and child of a button?
***
Second, is there a convenient way to remotely trigger a transform animation in a displayable that is already showing? If, for example, I have an image within a screen and I want said image to shake when a button is pressed, or when a function is executed, how could I force the animation to run?

Because the object is already showing and I want to keep it showing, I feel like "on show/on hide" is not what I'm looking for, but I don't know how to make a transform activate arbitrarily "on" some event external to it.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3795
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Two animation questions

#2 Post by Imperf3kt »

I haven't got an answer for you, but just wanted to point out that buttons changing size while hovered causes some funky behaviour while your cursor is near the edge and depending on how bad it is, can cause flickering that may trigger responses from epileptics
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Two animation questions

#3 Post by Kia »

You can achieve the first by containing a `button` and a `text` inside a `fixed`, then abuse a time to run a function that changes the size and the text length.

For the second, you can just use an `if...else` to swap between two objects with different animations.

Code: Select all

if is_shaking:
   add "image" at shaking
else:
   add "image" at other_animation
And like Imperf3kt mentioned, beware of funky behavior, they will occur in both cases and you have to have remedies in your code to deal with them.

Post Reply

Who is online

Users browsing this forum: No registered users