[Solved] Looking for the right event handler for a transform

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
Adrian_DVL
Regular
Posts: 114
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

[Solved] Looking for the right event handler for a transform

#1 Post by Adrian_DVL » Wed Jan 20, 2021 2:40 pm

Hi!

Okay, so in a nutshell: I have a screen with an imagebutton that changes a variable. When that variable changes, some images in the screen are replaced by others with the same size and in the same position. So far, so good: the player clicks a button and some of the images in the screen may change due to a variable changing its value.

What I want to do is to make a 'pulse' effect that makes the images that are replaced for others to zoom in and out in a second, IF AND ONLY IF they're actually replaced, since the screen has more buttons that may change other variables or may do nothing. I have this transform with no event handler at all. I tried some event handlers with no success:

Code: Select all

transform res(rxs, rys, rxp, ryp):
        size (rxs, rys)
        pos (rxp, ryp)
        easeout 0.1 pos (rxp-8, ryp-8) size (rxs+12, rys+12)
        easein 0.05 pos (rxp, ryp) size (rxs, rys)
I necessarily have to pass the size and the position of the images as parameters, since there are a bunch of those images on the screen. Now this is the animation I want for my images but, as I said, I want this to be executed ONLY when the player clicks a specific button on the screen ONLY for the image or images that are replaced due to the change of the variable that the button causes. I tell this because I've tried using 'on update', which is the most obvious event handler for this case, but with it, ALL the images that have 'at res' zoom in and out at once, no matter which button the player clicked and whether or not a variable changed, and not just the ones replaced due to the variable change, which is what I want.

So any ideas? I want only the images that are replaced due to a variable change to zoom in and out when the player clicks a button. I'd post an example of one of the buttons and one of the images, but I thought this would be simpler.
Last edited by Adrian_DVL on Thu Jan 21, 2021 10:26 am, edited 1 time in total.

User avatar
_ticlock_
Veteran
Posts: 393
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Looking for the right event handler for a transform

#2 Post by _ticlock_ » Wed Jan 20, 2021 10:33 pm

Hi, Adrian_DVL,

That's doable, although there is no straightforward way to achieve it (there is no magic event handler that solves all your problems).
I think this post may give you some ideas.

User avatar
Adrian_DVL
Regular
Posts: 114
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Looking for the right event handler for a transform

#3 Post by Adrian_DVL » Thu Jan 21, 2021 10:26 am

_ticlock_ wrote:
Wed Jan 20, 2021 10:33 pm
Hi, Adrian_DVL,

That's doable, although there is no straightforward way to achieve it (there is no magic event handler that solves all your problems).
I think this post may give you some ideas.
That post gave me an idea, and I set a net of variables that are used to tell the game whether a button has been clicked and when the rest of the buttons are not selected. The thing is that I had to create a class with one parameter per type of variable and a function that sets everything to False to be executed upon clicking every button before setting the pertinent parameter to True, due to the complexity of the screen, but I'm good to go now, so thanks!

Post Reply

Who is online

Users browsing this forum: Google [Bot]