Screen overlay
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.
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.
Screen overlay
How to make a certain screen (it's a stats screen) always be over 3 screens whenever those 3 screens are active? Thanks!
Re: Screen overlay
In theory, this works with the function "renpy.get_screen". An example could look like the following.
Code: Select all
###############
#Status screen
screen my_stats():
zorder 1000 # on top of all other screens
if (renpy.get_screen("my_screen1") and renpy.get_screen("my_screen2") and renpy.get_screen("my_screen3")):
frame:
xalign 0.5 yalign 0.5
vbox:
text "My Stats..."
timer 0.5 repeat True action [Show("my_stats")] # this will redraw this screen every 0,5 seconds
###############
# demo screens
screen my_screen1():
vbox:
xpos 0.1 ypos 0.1
text "mytext1"
screen my_screen2():
vbox:
xpos 0.5 ypos 0.1
text "mytext2"
screen my_screen3():
vbox:
xpos 0.8 ypos 0.1
text "mytext3"
###############
# The game starts here.
label start:
show screen my_stats # the screen which is redrawn every 0.5 seconds
"showing screen1"
show screen my_screen1 # demo screen 1
"showing screen2"
show screen my_screen2 # demo screen 2
"showing screen3"
show screen my_screen3 # demo screen 3
"Showing STATS" # because all 3 screens are shown
hide screen my_screen2
"Not showing STATS" # because one screen is hidden
returnWhy on earth did I put the bread in the fridge?
Re: Screen overlay
This seems way more complicated that necessary. If you want a screen to appear on top of another screen, just make sure its `zorder` property is higher. You can show the screen any of the usual ways -- if it's something you want to stay permanently visible like a stats screen, just do:
Variables displayed in the status screen should just update automatically, any time you change their values.
Code: Select all
screen status_overlay():
style_prefix "status"
zorder 12
vbox:
text _("Week [gametime.week], [gametime.day_name], [gametime.hour]h00")
text _("Credit: $[gk_credit]k")
if g_population > 0:
text _("Population: [g_population]")
Code: Select all
# The game starts here.
label start:
show screen status_overlay()
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: Screen overlay
Thanks you so much!
Who is online
Users browsing this forum: Google [Bot]