I have a problem with my portrait code:
I layer multiple images above each other to add eyes/mouth and stuff.
Everything works fine, but when I use a transform with alpha and a light background you can see where the other images are added, because the opacity is not the same.
Is there a possibility to check, if a transform is running so I could adjust the opacity of the overlayed images to make it less obvious?
Or is there a possibility to combine everything put into a render so it's one image when the opacity is applied?
I simplyfied my code, (it's much more complicated than this in the original because of various blinking/lip flap and other animations, but it displays the effect I mean):
Code: Select all
define e = Character('Eileen', color="#c8ffc8")
image bg white = Solid("#FFFFFF")
image portrait = Portrait(width=438, height=491)
# The game starts here.
label start:
show bg white
e "You've created a new Ren'Py game."
show portrait at fade_and_slide(300, 361, 75, 75, 1.0, 2.0)
e "Once you add a story, pictures, and music, you can release it to the world!"
return
init python:
class Portrait(renpy.Displayable):
def __init__(self, width=300, height=600, xpos=0, ypos=0, **kwargs):
try:
global characterSprites
super(Portrait, self).__init__(**kwargs)
self.width = width
self.height = height
self.xpos = xpos
self.ypos = ypos
except Exception as ex:
renpy.log(str(ex))
# def event(self, ev, x, y, st):
def per_interact(self):
renpy.display.render.redraw(self, 0)
super(Portrait, self).per_interact()
def render(self, width, height, st, at):
portrait_render = renpy.display.render.Render(self.width + self.xpos, self.height + self.ypos)
one = renpy.render(Image("images/sylvie_normal.png"), self.width, self.height, st, at)
two = renpy.render(Image("images/sylvie_normal_eyes.png"), self.width, self.height, st, at)
portrait_render.blit(one, (self.xpos, self.ypos))
portrait_render.blit(two, (self.xpos, self.ypos))
# Return the render.
flatten_portrait = renpy.display.render.Render(self.width, self.height)
flatten_portrait.blit(portrait_render, (0, 0))
return flatten_portrait
transform fade_and_slide(sx, tx, sy, ty, z, d):
on show:
zoom z
parallel:
alpha 0.0
linear d alpha 1.0
parallel:
xpos sx
linear d xpos tx
parallel:
ypos sy
linear d ypos ty
on hide:
zoom z
parallel:
alpha 1.0
linear d alpha 0.0
parallel:
xpos tx
linear d xpos sx
parallel:
ypos ty
linear d ypos sy