Sunday 7 February 2016

Easing / Warpers in Ren'Py

Version 6.99.8 of Ren'Py which was released in December 2015 includes these cool new warpers for making animations look smoother/more natural and/or more interesting!

You can see what sort of effect you get on this site:

http://easings.net/

And here is the Ren'Py documentation:
http://www.renpy.org/doc/html/atl.html#warpers

I thought I'd share a little bit of example code for using the cool new warpers in Ren'Py.

--

Here is my code using the easein_back movement:

I have this in my Script file, with the other images I am declaring:

image onion_ani:
    "onion.png"
    xpos 250
    ypos 750
    easein_back 2.5 xpos 550 ypos 500


And then in the game it's just a matter of showing the image:

    show onion_ani
    pause (4.0)
    hide onion_ani with dissolve


The code after the image declaration shows the image at the location provided by xpos and ypos (in this case 250 and 750) then using the nice easein_back movement it goes to the new xpos and ypos ( the 2.5 you see in my example is the amount of time in seconds this takes and the 550 and 500 are the new positions).

Later after "label start:" (i.e. somewhere in the main script of the game) it's shown with the show statement. In my example I also added a 4 second pause and the hide statement, they aren't needed at all for this, but I've included them just in case it helps anybody out at all.

---

It should have been fairly obvious to me that "easein_back" should go in place of "ease". But... I've never really used "ease" - all my old ATL code uses "linear", which is why I spent a while figuring out how to use these functions! I know I always get on better with code examples than I do with documentation (especially when I'm trying to do something quickly!).

Thanks to nyaatrap on lemmasoft forums for the original post http://lemmasoft.renai.us/forums/viewtopic.php?f=51&t=35749

And of course to renpytom (https://twitter.com/renpytom) for including them and Robert Penner (http://robertpenner.com/easing/) who, like, invented the original code :D