Ren'Py Minor coding question with short animation

TessSadist

Well-Known Member
Donor
Game Developer
Aug 4, 2019
1,298
5,535
Hi all,

Just a basic question -- I am trying to get a simple animation to play just once, then fade to another image without it reverting back to the prior image. (which is what is happening briefly right now) I've been a dev a bit now, but still a complete newbie to code and have never done an animation in my game yet at all. I can now successfully do a looping animation just fine (this works with certain animations fine to me) but another one I want to just show once. (single loop)

I already took out my original code and gave up on it for now, but I basically did:

image x = Movie(play="images/x.webm", Loop = False)
show image x with fade
scene e6tp23 (it's the next image) with mediumdissolve

I tried to put in a $ renpy.pause (2.0) type thing in there too but I can't seem to get it right. I just want it to go Prior image shows (tp22), then the animation plays once without a loop, and then it transitions from that to image tp23 as dialogue continues. (without kind of jumping back to 22)

I must be missing something simple -- any suggestions?
 

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,548
Hi all,

Just a basic question -- I am trying to get a simple animation to play just once, then fade to another image without it reverting back to the prior image. (which is what is happening briefly right now) I've been a dev a bit now, but still a complete newbie to code and have never done an animation in my game yet at all. I can now successfully do a looping animation just fine (this works with certain animations fine to me) but another one I want to just show once. (single loop)

I already took out my original code and gave up on it for now, but I basically did:

image x = Movie(play="images/x.webm", Loop = False)
show image x with fade
scene e6tp23 (it's the next image) with mediumdissolve

I tried to put in a $ renpy.pause (2.0) type thing in there too but I can't seem to get it right. I just want it to go Prior image shows (tp22), then the animation plays once without a loop, and then it transitions from that to image tp23 as dialogue continues. (without kind of jumping back to 22)

I must be missing something simple -- any suggestions?
You dont need $ renpy.pause, just pause

image x = Movie(play="images/x.webm", Loop = False)
show image x with fade
pause (x)
show next image

the x is the length of the animation, play it locally and see how long it is and pause for that amount of time. I have done similar so it should work.
 
Last edited:
  • Like
Reactions: TessSadist

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
Just a basic question -- I am trying to get a simple animation to play just once, then fade to another image without it reverting back to the prior image.
Then you are looking for the image property of the object:
image
An image that is displayed when play has been given, but the file it refers to does not exist. (For example, this can be used to create a slimmed-down mobile version that does not use movie sprites.) Users can also choose to fall back to this image as a preference if video is too taxing for their system. The image will also be used if the video plays, and then the movie ends.

image x = Movie(play="images/x.webm", Loop = False)
show image x with fade
scene e6tp23 (it's the next image) with mediumdissolve
Code:
image x = Movie(play="images/x.webm", Loop = False, image="images/e6tp23.jpg")

[...]
show image x with fade
scene e6tp23 (it's the next image) with mediumdissolve
 
  • Like
Reactions: TessSadist

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Just a quick note before I offer an alternative answer...

I've always favored pause {time} over $ renpy.pause({time}).
But it was pointed out to me last week that pause alone can behave like a transition. So if a player goes into the options and ticks the "skip transitions" option, then those pauses will be skipped. Whereas $ renpy.pause({time}) will still wait the given time.

Overall, $ renpy.pause({time}) sounds like the better bet.

Meanwhile... the original question.

My solution would be to use , to create a pseudo animation using both the video file and the static image you want to replace it.

Python:
image playonce_scene:
    Movie(play="movies/anne_vid2.webm")
    1.5
    "intro1" with dissolve

label start:

    scene black with fade
    "*** START ***"

    scene playonce_scene with fade
    "Yay!... A video."

    "*** THE END ***"

    return

I'm using scene playonce_scene with fade to avoid the problem of the video briefly showing a transparent background before playing.

Then I'm using "intro1" with dissolve to dissolve from the movie into the picture intro1... which is just an automatically assigned displayable name for images/intro1.jpg.

Obviously vary the 1.5 delay depending on how long the video file is in seconds.
 
Last edited:
  • Like
Reactions: TessSadist

TessSadist

Well-Known Member
Donor
Game Developer
Aug 4, 2019
1,298
5,535
I'll read over this carefully and test when I get home later and thanks to all :)