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.
I want to add a dissolve from one image to another inside the screen when the variable changes, it should be simple to do but I can't think of any solution for some reason.
here's my code:
Alex wrote: ↑Fri Oct 11, 2019 2:36 pm
Try to show images using 'showif' statement
it might come in handy if I end up having to use two images to alternate between but it's not exactly what I'm looking for since I can't hardcode hundreds of images into my screen using shoif.
like always there are hacky solutions but I'm looking for a more elegant way to do it
This probably rises to somewhere around the level of getting a bit uncomfortable on the hackometer, but perhaps if nothing else it can help inspire better solutions. Note that the variables blue and green misleadingly (I know, I'm sorry!) have no impact on the image displayed and are referencing instead the concept of blue/green deployment.
image r = Solid('f77', xysize=(200, 200))
image b = Solid('7f7', xysize=(200, 200))
image g = Solid('77f', xysize=(200, 200))
label start:
show screen imgswap('r')
'Start at red, fade to others and back.'
return
transform imgswap_top:
on show, appear:
linear .2 alpha 1.
on hide:
linear .2 alpha 0.
transform imgswap_bottom:
on show, appear:
alpha 1.
on hide:
.2
alpha 0.
screen imgswap(img=None):
default blue = img
default green = img
default swap = False
python:
if blue != green:
swap = not swap
if not swap:
blue, green = green, blue
vbox:
fixed:
xfit True
yfit True
showif swap:
add blue at imgswap_bottom # if images have alpha, use imgswap_top here
text 'blue'
else:
add green at imgswap_top
text 'green'
button:
text 'red'
action SetScreenVariable('blue', 'r')
button:
text 'green'
action SetScreenVariable('blue', 'b')
button:
text 'blue'
action SetScreenVariable('blue', 'g')
python:
if swap:
green = blue
else:
blue = green
Alex wrote: ↑Mon Oct 14, 2019 11:17 am
Well, another try inspired by strayerror's post in other thread...
well, after you suggested showif I did wrote a hack similar to what strayerror wrote, if we look past the fact that to keep the container size constant I had to add a copy of the image at alpha 0.0 underneath and if the images sizes are different there would be a jump in position. it does work.
using the screen transitions never crossed my mind, but it would be a bit more limited than shiwif since it needs a screen for each if we want to display more than one image at the same time.
I was hoping for one of those user defined displayables that handle their own render, but I'm not confidence in my skills to tackle UDD myself.
Kia wrote: ↑Mon Oct 14, 2019 5:32 pm
...but it would be a bit more limited than shiwif since it needs a screen for each if we want to display more than one image at the same time. ...
It looks like using '_tag' argument lets us show the same screen several times - try to play with it...