Showing Animations on a Screen

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
Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Showing Animations on a Screen

#1 Post by Glazed Donuts »

What would be the Screen Language equivalent for showing/hiding an animated image? For example, this works when I'm NOT in a Screen block of code:

Code: Select all

image test = Animation("sozai/anim/1.png", 0.08,
                                "sozai/anim/2.png", 0.08,
                                "sozai/anim/3.png", 0.08,
                                "sozai/anim/4.png", 0.08,
                                "sozai/anim/5.png", 0.08) 

show test with dissolve
However, if I do this under a Screen block, I will get errors. Is there a Screen language equivalent for doing the above? (or at least, for showing the animated image?)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Showing Animations on a Screen

#2 Post by Alex »

I think it can be a combination of ATL image and screen that shows that image, like

Code: Select all

init:
    image test:
        "sozai/anim/1.png"
        0.08
        "sozai/anim/2.png"
        0.08
        "sozai/anim/3.png"
        0.08
        "sozai/anim/4.png"
        0.08
        "sozai/anim/5.png"
        0.08
        repeat

screen test_scr:
    add "test"

label start:
    scene black
    "..."
    show screen test_scr
    "... ..."
    hide screen test_scr
    "___"
http://www.renpy.org/doc/html/screens.html#add

Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Re: Showing Animations on a Screen

#3 Post by Glazed Donuts »

Why is this:

Code: Select all

init:
    image test:
        "sozai/anim/1.png"
        0.08
        "sozai/anim/2.png"
        0.08
        "sozai/anim/3.png"
        0.08
        "sozai/anim/4.png"
        0.08
        "sozai/anim/5.png"
        0.08
        repeat
better to use than this?

Code: Select all

image test = Animation("sozai/anim/1.png", 0.08,
                                "sozai/anim/2.png", 0.08,
                                "sozai/anim/3.png", 0.08,
                                "sozai/anim/4.png", 0.08,
                                "sozai/anim/5.png", 0.08) 
Does the screen language not recognize the 'Animation' keyword when you try to call the image?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Showing Animations on a Screen

#4 Post by Alex »

It's not "better then", it's just an example of ATL. Animation should work too.

User avatar
Rosstin
Veteran
Posts: 368
Joined: Mon Jan 31, 2011 5:43 pm
Completed: Rex Rocket, Kitty Love, King's Ascent
Projects: Road Redemption, Queen At Arms
Organization: Aqualuft Games
Contact:

Re: Showing Animations on a Screen

#5 Post by Rosstin »

I'm having a minor problem with my animation display in my game right now. My battle animations seem to start in the middle rather than at the beginning. Is this due to slowdown? Is there a way to force the game to preload the animation before attempting to loop it, so it starts at the first frame?

I can think of a number of kludge fixes, such as including a number of static starting frames. But it'd be nice to just flip a "preload" flag or somesuch.
Image

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Showing Animations on a Screen

#6 Post by Alex »

Well, it might be your sprites, used in animation, or a big image that will appear in some lines next to animation (check up to 10 lines of code). In any case renpy.cache_pin should help you.

User avatar
Rosstin
Veteran
Posts: 368
Joined: Mon Jan 31, 2011 5:43 pm
Completed: Rex Rocket, Kitty Love, King's Ascent
Projects: Road Redemption, Queen At Arms
Organization: Aqualuft Games
Contact:

Re: Showing Animations on a Screen

#7 Post by Rosstin »

Hey, kickass. That function looks like it would be helpful.

My game has extremely heavy animation, though. Like, a typical battle animation has 20 frames. Do I have to preload every single frame?
Image

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Showing Animations on a Screen

#8 Post by Alex »

As far as I know, Ren'py loads images everytime they need to be shown. So, if you don't want it, then preload all frames while init phase.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Showing Animations on a Screen

#9 Post by PyTom »

Ren'Py will preload images used on screens, as long as there's enough room for them and it's given enough time to do so. Generally, renpy.cache_pin shouldn't be used - consider increasing config.image_cache_size from the default of 8 instead.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot], Vamp-sama