The key behind side images is that they use image tagging. In Ren'Py, you can give a tag to an image, and any image you give with the same tag replaces the old image.
The 'as' clause in the show statement is useful for retagging an image:
Code: Select all
show bill at left as leftchar
show dave as leftchar with Dissolve(0.3)
# Dave will replace Bill, since they share tags.
The side images system in Ren'Py is a pre-written feature that takes advantage of the engine's image tagging. But you can use image tagging by itself, in a simpler way.
You could use the above script as an example, but it's still a little tedious to write the transition each time. I know that PyTom recently added 'tag_layer' and 'tag_transform' to the configuration variables, letting you define automatic layers and/or transforms for certain image tags; maybe 'tag_transition' would be a good addition in the future.
Another, more advanced thing you can do is use 'config.show', and create a Python function that can intercept and/or filter the show statement. Here, how about something like this:
Code: Select all
init python:
def filter_show(name,at_list,layer,what,zorder,tag,behind,atl):
if left in at_list:
tag = "leftchar"
if right in at_list:
tag = "rightchar"
renpy.show(name,at_list,layer,what,zorder,tag,behind,atl)
if (tag == "leftchar" or tag == "rightchar"):
renpy.with_statement(dissolve)
config.show = filter_show
Code: Select all
# Anything 'at left' or 'at right' will replace the previous image there, and do a transition
show bill at left
bill "Hello."
show dave at right
dave "Hello, Bill. Oh, I see you brought Sarah."
show sarah at left
sarah "Hi, Dave!"
EDIT: There are some limitations to what I wrote - any image put on the left or right will be named 'leftchar' or 'rightchar', so if you wanted to use say attributes in your dialogue, it wouldn't work.
Here's an alternate method:
Code: Select all
init python:
recent_left = ("no image")
recent_right = ("no image")
def filter_show(name,at_list,layer,what,zorder,tag,behind,atl):
global recent_left,recent_right
if left in at_list:
renpy.hide(recent_left)
recent_left = name
if right in at_list:
renpy.hide(recent_right)
recent_right = name
renpy.show(name,at_list,layer,what,zorder,tag,behind,atl)
if left in at_list or right in at_list:
renpy.with_statement(dissolve)
config.show = filter_show
# Set a transition for changes made in dialogue
config.say_attribute_transition = dissolve
Code: Select all
show bill at left
bill "Hello everyone."
bill happy "It is good to see you all."
show dave at right
dave "Welcome, Bill. Oh, hello Sarah."
show sarah at left
sarah "Hello!"