Help please - Trying to get a simple blink animation to work

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
willanik
Regular
Posts: 35
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Help please - Trying to get a simple blink animation to work

#1 Post by willanik »

Hi,

I want to make a simple animation by alternating between two or three images, for example like the blinking character in this video - https://www.youtube.com/watch?v=iixZ4CnswzY
But I cannot get it to work!

I have set up a simple trial. I have added images 1 and 2 to my image file as pngs. They are sized to fit the screen. Then, as per the video, I have coded as follows:

Code: Select all

image 1 = "1.png"
image 2 = "2.png"

# animation

image blink:
     "1.png"
      2
      "2.png"
      0.2
      repeat 
    
# The game starts here.

label start:

    scene background 

    pause

    show blink

    return
The result is that on Start Game my background comes up as expected, but when I hit Enter I just go back to the main menu. The blink images do not come up.

Any ideas what I am doing wrong? Or, happy to be shown a link to an alternate way of making a simple animation.
Many thanks for any help you can provide!

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Help please - Trying to get a simple blink animation to work

#2 Post by Donmai »

Your image is showing but you don't have enough time to see it before it disappears in a blink (sorry, couldn't resist).
Add another pause or a line of dialogue after showing the image (even a blank dialogue line will do) to make the program wait for an user action. That should give you time to see the image.

Code: Select all

label start:

    scene background 

    pause

    show blink
    "Is it blinking?"

    return
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

willanik
Regular
Posts: 35
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#3 Post by willanik »

Fantastic! Thanks Donmai.
I made your change and it was fixed in the blink of en eye!

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Help please - Trying to get a simple blink animation to work

#4 Post by Donmai »

:lol: I'm glad I could help.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

willanik
Regular
Posts: 35
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#5 Post by willanik »

Ok, so my blink works! Now I am moving on to having a character wave his arm. I can write the code to make the waving animation (as below), but the result looks very jerky.

image waving:
"01.jpg"
0.2
"02.jpg"
0.2
"03.jpg"
0.2
"04.jpg"
0.2
"03.jpg"
0.2
"02.jpg"
0.2
repeat

Is there any additional code I can use to smooth out the transitions? Thanks for any help you can give me!

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#6 Post by kivik »

Human eye blinking is so fast that you barely ever noticed that you've blinked - hence the expression at the blink of an eye - it's perceivably just your eyes going from opened to closed and back to opened again, that's why a few frames work.

Hand waving on the other hand, is much slower, so unless you're waving it inhumanly fast, you'd need a lot more frames to make it smooth looking - consider films are shown at 24 frames per second, phone videos and consoles at 30fps, PC games and newer consoles at 60fps - your 5fps animation will inevitably be jerky.

You've got a few options - one is to actually go the opposite way - and go for 2 frames > starting and ending frame. I'm sure may NVL games does that to indicate a character's physical motions. This is the path I'd recommend

Two, is to try using the rotate property: https://www.renpy.org/doc/html/atl.html ... rty-rotate. I will most likely look very weird though, at best it'd look like puppetry.

Three, is to create more frames in between - but there's something else to also bear in mind - even at 24fps with still frames, your waving motion will still look odd: films and videos aren't just showing at their specific frame rate, they're also shot at the same frame rate, which means motion blur is introduced to smooth out the picture. That's why you can't shoot a video at 60fps and convert it to 24fps easily.
When Matrix first did bullet time, they had to do computer to digitally introduce frame blending because no motion blur were introduced to the frames, as they used lots of still cameras. You can actually notice the distortion if you watch it carefully.


TLDR; use 2 frames and longer pause in between is your best option :)

willanik
Regular
Posts: 35
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#7 Post by willanik »

Thanks Kivik, good information.

I guess I was also hoping that I could add some code to blur the transition between images. A bit like 'with dissolve' can do in other situations.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#8 Post by kivik »

You can add dissolve to your animation, it still won't come out like waving as it won't blur the movement, but it's probably a good option.

Here's an example of adding dissolve in an animation https://www.renpy.org/doc/html/atl.html ... -statement

Combine it with repeat x for just the first and last frame should work.

willanik
Regular
Posts: 35
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Help please - Trying to get a simple blink animation to work

#9 Post by willanik »

Thanks again, I'll read through the info on that link and do some experimenting!

Post Reply

Who is online

Users browsing this forum: Google [Bot]