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
Newbie
Posts: 10
Joined: Fri Oct 04, 2019 3:02 pm
Deviantart: bloobeary
Soundcloud: user-212448702
Contact:

animated graphic timer using screens?

#1 Post by bloobeary » Sat Oct 05, 2019 9:37 am

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: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: animated graphic timer using screens?

#2 Post by xavimat » Sat Oct 05, 2019 9:48 am

Try:

Code: Select all

add "greentimer60"
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

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

Re: animated graphic timer using screens?

#3 Post by bloobeary » Sat Oct 05, 2019 12:56 pm

Yep. That worked, thanks!

Post Reply

Who is online

Users browsing this forum: Google [Bot]