▪ Show a Timer that is similar to the one on the Ren'py tutorial?
▪ How do I make it 99 seconds instead of 10?
▪ Make it jump to a label by force once it reaches 00.00?
▪ Dictate the font and the size?
▪ Dictate the position in pixels?
Code: Select all
init:
python:
# This function will run a countdown of the given length. It will
# be white until 5 seconds are left, and then red until 0 seconds are
# left, and then will blink 0.0 when time is up.
def countdown(st, at, length=0.0):
remaining = length - st
if remaining > 2.0:
return Text("%.1f" % remaining, color="#fff", size=72), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=72), .1
else:
return anim.Blink(Text("0.0", color="#f00", size=72)), None
# Show a countdown for 10 seconds.
image countdown = DynamicDisplayable(countdown, length=5.0)Code: Select all
show countdown at Position(xalign=.1, yalign=.1)Code: Select all
image countdown = DynamicDisplayable(countdown, length=5.0)Code: Select all
length=5.0Code: Select all
length=99.0Code: Select all
show countdown at Position(xalign=.1, yalign=.1)
$ ui.timer(5.0, ui.jumps("slow"))
menu:
"Yes":
jump yes
"No":
jump no
label slow:
hide countdown
"You're too slow."
label yes:
hide countdown
"..."
label no:
hide countdown
"..."Code: Select all
screen timer(duration=5):
default time = duration
timer 1.0:
repeat True
action [
SetScreenVariable("time", time - 1),
If(time == 0, SetScreenVariable("time", duration))
]
text str(time) align (0.5, 0.5)
label start:
show screen timer(10)
"Countdown!"
Users browsing this forum: Bing [Bot], Hojoo