animated graphic timer using screens?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
bloobeary
Regular
Posts: 36
Joined: Fri Oct 04, 2019 3:02 pm
Deviantart: bloobeary
Soundcloud: user-212448702
Contact:

animated graphic timer using screens?

#1 Post by bloobeary »

So, here's my situation - I'm trying to create a graphical countdown timer.

I have a sequence of PNG images of an LED timer unit, with each image representing one second of the countdown. I've found that I can turn these into an animated graphic by defining them in script.rpy as an image, thusly:

image greentimer60:
size(300,300)
"timers/60sec-green/green60-01.png"
pause 1
"timers/60sec-green/green60-02.png"
pause 1
"timers/60sec-green/green60-03.png"
pause 1
"timers/60sec-green/green60-04.png"

...and so on

The problem is that I would like this timer to remain onscreen across multiple scene changes.
If I just use:

show greentimer60

...then the timer graphic will disappear as soon as the first scene transition happens.

So, I thought maybe I could make it into a screen, since screens can persist across multiple scenes, but at the moment I can't figure out a way to do that. It doesn't appear that I can simply call the existing graphic into a screen:

screen demotimer():
fixed:
add greentimer60

...because this results in a "greentimer60 not defined" error. And copying the defining image code from script.rpy to screens.rpy didn't seem to work either.

Is there a way to actually do this?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: animated graphic timer using screens?

#2 Post by xavimat »

Try:

Code: Select all

add "greentimer60"
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

bloobeary
Regular
Posts: 36
Joined: Fri Oct 04, 2019 3:02 pm
Deviantart: bloobeary
Soundcloud: user-212448702
Contact:

Re: animated graphic timer using screens?

#3 Post by bloobeary »

Yep. That worked, thanks!

Post Reply

Who is online

Users browsing this forum: No registered users