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.
Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
I tried to use Asceai's code for TransitionConditionSwitch viewtopic.php?f=51&t=26612#p326683. This does have a transition effect which I wish I could have something like that in layerimages(i just like the design ).
But I now get and error when using TransitionConditionSwitch within LiveComposite, called:
File "game/characters.rpy", line 152, in per_interact
if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
I am not so good with OOP but I understand the issue is with "change_to".
I tried to use Composite but I am still getting same error. i assume in the past it worked well, but now there have been many updates for Ren'py and python 3.xx so something has changed.
I know layeredimages do take ATL and you can apply ATL for every expression like this:
show person
with dissolve #or renpy.transition(dissolve, layer="master") #Applies transition only to images that are in master layer.
Problem with this is that transition will be applied to the whole image where i want only for the expression to have the transition effect. (Not pleasing when you want to move the image while applying at the same time the transition dissolve, it looks weird when the image is moving.
Dark79 wrote: ↑Fri Mar 22, 2024 12:18 am
Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
It's probably like changing any other image, "with dissolve":
File "game/characters.rpy", line 152, in per_interact
if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
The error message says that when that line was executed, variable change_to was not defined.
Perhaps that error wouldn't happen if you insert at the very beginning of that function:
Dark79 wrote: ↑Fri Mar 22, 2024 12:18 am
Since I just cannot figure out how to use layeredimage the way i want to for example when I want to change expression, each expression change would have a transition effect (dissolve).
It's probably like changing any other image, "with dissolve":
File "game/characters.rpy", line 152, in per_interact
if change_to is not self.current_d:
UnboundLocalError: local variable 'change_to' referenced before assignment
The error message says that when that line was executed, variable change_to was not defined.
Perhaps that error wouldn't happen if you insert at the very beginning of that function:
File "game/characters.rpy", line 177, in per_interact
self.ta = anim.TransitionAnimation(self.old_d, 0.00, self.transition, self.current_d)
Exception: Not a displayable: None
I that was the last thing I tried before posting on the forums. I dunno maybe I am using it wrong way. I know that you use the ATL transition like normal transitions
But I am not sure how to use the transform ATL transition within layered image and I would rather use layerimage since its nicely organized, just sadly I can't figure out how to apply transitions when changing expressions.
I managed to give each expression an alpha dissolve but it is jarring as the face expression disappear completely and the next expression slowly appears. Hope this is somewhat helpful.
transform persona_appear:
on show:
alpha 0.0
linear 1.5 alpha 1.0
on hide:
linear .5 alpha 0.0
transform show_up:
alpha 0.0
linear 1.5 alpha 1.0
layeredimage smiler:
at persona_appear
always:
"smiley_base.png"
group face_reacts:
attribute smile default at show_up:
"smiley_def.png"
attribute surprised at show_up:
"smiley_surprise.png"
label start:
show beige_bg
show smiler
sm "I am smiling."
show smiler surprised
sm "But I get easily surprised!"
show smiler smile
sm "But I always manage to smile through it!"
hide smiler
sm "That's it."
piinkpuddiin wrote: ↑Sun Mar 24, 2024 4:51 pm
I managed to give each expression an alpha dissolve but it is jarring as the face expression disappear completely and the next expression slowly appears. Hope this is somewhat helpful.
transform persona_appear:
on show:
alpha 0.0
linear 1.5 alpha 1.0
on hide:
linear .5 alpha 0.0
transform show_up:
alpha 0.0
linear 1.5 alpha 1.0
layeredimage smiler:
at persona_appear
always:
"smiley_base.png"
group face_reacts:
attribute smile default at show_up:
"smiley_def.png"
attribute surprised at show_up:
"smiley_surprise.png"
label start:
show beige_bg
show smiler
sm "I am smiling."
show smiler surprised
sm "But I get easily surprised!"
show smiler smile
sm "But I always manage to smile through it!"
hide smiler
sm "That's it."
Thanks for the help, while this is not exactly like a proper dissolve effect but it's a start, I tried to use on "persona_appear" transform on the expression but this does not take any effect" like "on show" and "on hide" do not work. I also tried to use "persona_appear" in IF condition in layeredimage and see if that will give any different effect but nope, just instant appearing image expressions. Still thank you:)
As parts of layered image you can use images defined with ATL. You can apply transforms to those layer images, not affecting other layers. Example (try the attached script with files):
layeredimage augustina:
always:
"bg.jpg"
attribute happy:
"s2h_01.png"
align (0.65, 0.45)
xysize (400, 600)
attribute sad:
"s2h_15.png"
align (0.65, 0.45)
xysize (400, 600)
label start:
scene augustina
pause 1.0
show augustina happy
with dissolve
pause 1.0
show augustina -happy sad
with dissolve
pause 1.0
show augustina -sad happy
with dissolve
pause 1.0
"OK"
Thanks jeffster for the idea to use several images to achieve dissolve effect so I noted it down.
I don't prefer use "with dissolve" and if there is a lot of dialogue and a lot of changing expressions at the same time. I realised that using $ renpy.transition(dissolve, layer="master") instead "with dissolve" With this, it will apply the transition to the shown image at the same time while showing the new dialogue, instead of waiting for the image to finish it's transition and then the dialogue appears.
Ofcourse its a bit on the eye to see and type "$ renpy.transition(dissolve, layer="master")" all the time but it's the closest thing to TransitionConditionalSwitch to achieve similar effect so I will settle with this.
Thanks everyone for the help I greatly appreciate it.