Tutorial & Code: Analog/Digital Clock as User Defined Display
The article says it was updated in June 2016 and that Uncle Mugen's clock works in RenPy 6.18. It is July 2018 now and I'm using RenPy 7.0.0.
I tried the example clock code; it initially displayed the clock but as the minutes increased the hands stay still.
I managed to get it working by tweaking it a little:
Code: Select all
init:
$ minutes = 540
image hourhand = "hourhand.png" # Short Clockhand
image minutehand = "minutehand.png" # Long Clockhand
image clockface = "clockface.png" # Clockface
transform rotatelong(mins):
xanchor 0.5
yanchor 0.5
xalign 0.5
yalign 0.5
rotate (mins*6)
transform rotateshort(mins):
xanchor 0.5
yanchor 0.5
xalign 0.5
yalign 0.5
rotate (mins*0.5)
transform alpha_dissolve:
alpha 0.0
linear 0.5 alpha 1.0
on hide:
linear 0.5 alpha 0
# This is to fade in the clock.
screen clock:
text "minutes: [minutes]"
frame at alpha_dissolve:
xmaximum 250 # X size of clock graphic
ymaximum 250 # Y size of clock graphic
xalign 0.99 # X placement on screen
yalign 0.02 # Y placement on screen
add "clockface"
add "minutehand" at rotatelong(minutes)
add "hourhand" at rotateshort(minutes)
# The game starts here.
label start:
"What time is it?"
"Let's look at the clock."
show screen clock
"Ah!... Nice clock!"
"It is already 9:00AM."
"He is very late."
"But he is my friend so I will wait."
$ minutes += 2
"Two minutes has passed."
$ minutes += 2
"Four minutes has passed."
$ minutes += 2
"Six minutes has passed."
"HE IS LATE! I KILL HIM!"
hide screen clock
Is this change in behaviour documented somewhere? (or is it a bug?)
I'm trying to understand the rules of when variable changes would cause a screen to be updated.
Many thanks
Please excuse my RenPy or Forum etiquette ignorance.
