ConditionShowingSwitch and LiveComposite question
Posted: Fri Jun 30, 2017 6:51 pm
I have a "test game" with code for LiveComposite (for a sprite) and ConditionShowingSwitch (for a side image). When I run it, Ren'Py doesn't give me any errors, but the side image and dialogue box disappear during the dissolve transition I have set up for the sprite which is specified not in the LiveComposite, but when I call the defined image for the sprite). After the transition, both the side image and dialogue box reappear.
With regards to this, I have two questions:
1) Is it possible to apply the same dissolve transition to the side image?
2) What can I do to make the side image and dialogue box stay on screen during the sprite transitions? (I have more than one, and this issue happens with all of them.)
Between sprite facial expression transitions, the dialogue box and the side image disappear and reappear, instead of staying on the screen throughout. To elaborate, one such transition in the above code looks like this:
First the sprite appears with one facial expression, then the side image, as expected. When the same sprite with a new facial expression appears, the dissolve transition works great, but the previous side image disappears completely (along with the dialogue box). Then, the next side image and the dialogue box (with new dialogue) appear together.
Here is my script for reference:
I came across TransitionShowingSwitch in the past as a means of applying transitions to side images, and I implemented it successfully. Unfortunately, I got an error from Ren'Py when I tried running it post-update.
Here is the script for that:
And here is the traceback (*note: with my full name removed from the file paths):

With regards to this, I have two questions:
1) Is it possible to apply the same dissolve transition to the side image?
2) What can I do to make the side image and dialogue box stay on screen during the sprite transitions? (I have more than one, and this issue happens with all of them.)
Between sprite facial expression transitions, the dialogue box and the side image disappear and reappear, instead of staying on the screen throughout. To elaborate, one such transition in the above code looks like this:
Code: Select all
show girl-curious with dissolve
$ girl = 2
g "Are you learning how to use Ren'Py?"
show girl-happy with dissolve
$ girl = 0
g "That's great! Ren'Py is a lot of fun!"
Here is my script for reference:
Code: Select all
init:
#Backgrounds
image bg street = "BGs/bg_street.jpg"
image bg school hall = "BGs/school_hall.jpg"
image bg school grounds = "BGs/school_grounds.jpg"
#Sprites
image girl happy = "Sprites/Girl/girl_happy.png"
image girl embarassed = "Sprites/Girl/girl_embarassed.png"
image girl curious = "Sprites/Girl/girl_curious.png"
#Side Images
image girl happyside = "Sprites/Girl/Side Images/girl happy_side.png"
image girl embarassedside = "Sprites/Girl/Side Images/girl embarassed_side.png"
image girl curiousside = "Sprites/Girl/Side Images/girl curious_side.png"
#Characters with ConditionSwitch for side image
$ g = Character("Celeste", color = "#ffffff", show_side_image=ConditionSwitch('girl==0', 'girl happyside', 'girl==1', 'girl embarassedside', 'girl==2', 'girl curiousside', xalign=0, yalign=1.0), window_left_padding=200, ctc="ctc_blink", ctc_position="nestled", window_background="GUI/girl-text-box.png", what_xpos=0, what_ypos=5, who_xpos=2, who_ypos=0.0, show_two_window=True, show_who_window_style="say_who_window2")
$ mc = Character("Me", color = "#ffffff", show_two_window=True, show_who_window_style="say_who_window1")
#LiveComposite sprite facial expressions
image girl-happy = LiveComposite(
(374, 600), #(width, height) of the full size sprite
(0, 0), "Sprites/Girl/Full-Size/girl_happy.png", #this is needed to show the whole sprite
(111, 70), "Sprites/Girl/LC Expressions/happy0.png",
)
image girl-embarassed = LiveComposite(
(374,600),
(0,0), "Sprites/Girl/Full-Size/girl_embarassed.png",
(111,70), "Sprites/Girl/LC Expressions/embarassed0.png",
)
image girl-curious = LiveComposite(
(374,600),
(0,0), "Sprites/Girl/Full-Size/girl_curious.png",
(111,70), "Sprites/Girl/LC Expressions/curious0.png",
)
#Set auto-mode for the text as default
if not persistent.set_afm_time:
$ persistent.set_afm_time = True
$ _preferences.afm_time = 10
#Game starts here
label start:
scene bg street
with fade
mc "\"This is dialogue by me.\""
"This is narration."
label scene_A:
scene bg street
#this is how the next scene is defined
#this scene is what shows up in-game when the first menu option is clicked
"This is a scene from option A."
jump character_sprite
label character_sprite:
scene bg school hall with fade
$ girl = 0
show girl-happy at center with moveinleft
g "Hi! I'm a character sprite!"
show girl-curious with dissolve
$ girl = 2
g "Are you learning how to use Ren'Py?"
show girl-happy with dissolve
$ girl = 0 #this is defined in the init block as a side image condition switch
g "That's great! Ren'Py is a lot of fun!"
scene black with fade
return
Here is the script for that:
Code: Select all
init:
image girl happy = "Sprites/Girl/Full-Size/girl_happy.png"
image girl embarassed = "Sprites/Girl/Full-Size/girl_embarassed.png"
image girl curious = "Sprites/Girl/Full-Size/girl_curious.png"
$ c = Character("Celeste", window_left_padding=200,
show_side_image=TransitionShowingSwitch(Dissolve(0.5, alpha=True),
"girl happy", Image("Sprites/Girl/Side Images/girl happy_side.png"),
"girl curious", Image("Sprites/Girl/Side Images/girl curious_side.png"),
None, Image("Sprites/Girl/Side Images/girl happy_side.png"),
xalign=0.0, yalign=1.0)
)
transform basicfade:
on show:
alpha 0.0
linear 1.0 alpha 1.0
on hide:
linear 1.0 alpha 0.0
#LiveComposite code for full-size sprite facial expressions
image girl-happy = LiveComposite(
(374, 600), #(width, height) of the full size sprite
(0, 0), "Sprites/Girl/Full-Size/girl_happy.png", #this is needed to show the whole sprite
(111, 70), "Sprites/Girl/LC Expressions/happy0.png", #(111,70) is how far the facial expression is in pixels from the top and left of the full size sprite image
#happy0.png is just the girl's happy face (cropped image from the full size sprite)
)
image girl-embarassed = LiveComposite(
(374,600),
(0,0), "Sprites/Girl/Full-Size/girl_embarassed.png",
(111,70), "Sprites/Girl/LC Expressions/embarassed0.png",
)
image girl-curious = LiveComposite(
(374,600),
(0,0), "Sprites/Girl/Full-Size/girl_curious.png",
(111,70), "Sprites/Girl/LC Expressions/curious0.png",
)
init-1 python:
class TransitionShowingSwitch(renpy.Displayable):
def __init__(self, transition, *args, **kwargs):
super(TransitionShowingSwitch, self).__init__(**kwargs)
self.layer = kwargs.pop('layer', 'master')
self.transition = transition
self.d = zip(args[0::2], args[1::2])
self.time_reset = True
self.old_d = None
self.current_d = None
self.ta = None
self.old_st = 0
def render(self, width, height, st, at):
if self.time_reset:
self.time_reset = False
self.st = st
self.at = at
self.old_st = 0
if st < self.old_st:
self.st, self.at, st, at = 0, 0, 1000000.0, 1000000.0
self.old_st = st
return renpy.render(self.ta, width, height, st-self.st, at-self.at)
def per_interact(self):
if renpy.display.predict.predicting:
return
for name, d in self.d:
if name is None or renpy.showing(name, layer=self.layer):
change_to = d
break
if change_to is not self.current_d:
self.time_reset = True
self.old_d = self.current_d
self.current_d = change_to
if self.old_d is None:
self.old_d = self.current_d
self.ta = anim.TransitionAnimation(self.old_d, 0.00, self.transition, self.current_d)
renpy.redraw(self, 0)
def visit(self):
return [ self.ta ]
label start:
show girl happy at center with basicfade
c "Hello!"
c "My name is Celeste!"
show girl curious
c "What's your name?"
return
Any help on this would be much appreciated!I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 89, in script
show girl happy at center with basicfade
Exception: Parameter 'new_widget' is not known by ATL Transform.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\bootstrap.py", line 295, in bootstrap
renpy.main.main()
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\main.py", line 487, in main
run(restart)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\main.py", line 147, in run
renpy.execution.run_context(True)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\execution.py", line 761, in run_context
context.run()
File "game/script.rpy", line 89, in script
show girl happy at center with basicfade
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\ast.py", line 1275, in execute
renpy.exports.with_statement(trans, paired)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\exports.py", line 1381, in with_statement
return renpy.game.interface.do_with(trans, paired, clear=clear)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2096, in do_with
clear=clear)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2746, in interact_core
new_widget=layers_root)
File "C:\Users\__________\Documents\Ren'Py VN Engine\renpy-6.99.12.4-sdk\renpy\atl.py", line 413, in __call__
raise Exception('Parameter %r is not known by ATL Transform.' % k)
Exception: Parameter 'new_widget' is not known by ATL Transform.