jdeisenberg wrote:
The problem is that the image created by make_drawing() disappears after joe's dialog. I'd like to be able to make the code generate a displayable so that I could say (pseudo-code)
Code: Select all
$ displayable_thing = make_drawing(3, 5)
show displayable_thing
joe "Wow, 3 really is less than 5."
fred "Yes, and the diagram is still there, too!"
All of the ui.* functions have Displayable equivalents... (or more accurately, I believe, Displayable classes which are used by the ui.* classes to create the UI).
If you check the
Layout section of the Displayables page of the manual it'll show you how to create the Displayable instances you need - so you'll create the
Image you want first, and then create the
Fixed and pass the Image as the first parameter.
However, because you're not using the Ren'Py 'image' keyword and you [presumably] won't be doing this in an init block anyway, you won't be able to just use Ren'Py-script to "show myDisplayableVariableName"; instead you can call
renpy.show from Python, passing in a string tag name by which you identify your displayed Displayable (and can use later to hide it with renpy.hide), and the Displayable instance you created as the 'what' parameter. If you need to position it, you could pass a 'style' parameter to each UI element you create, or you can pass a
Transform object in a list into the 'at_list' parameter, e.g.:
Code: Select all
python:
myFixed = Fixed(...)
tran = Transform(xpos=0.25, ypos=0.5, xanchor=0.5, yanchor=0.5)
renpy.show("myFixedImageTag", what=myFixed, at_list=[tran])
joe "Hey, there's the diagram"
fred "Indeed. Pretty cool!"
$ renpy.hide("myFixedImageTag")
joe "Now it's gone."
Bear in mind that if you just show stuff like that, it'll go into the 'master' layer. UI normally goes into the 'transient' layer (which IIRC gets cleared automatically after every interaction, such as clicking away dialogue, which is why it was disappearing after one line before), which is above 'master', so a UI element displayed like that will go behind the dialogue box. If you want it in front (without adding new layers yourself) then you could add the parameter 'layer="overlay"' to both the 'renpy.show' and the 'renpy.hide' calls.