Page 1 of 1

Simplifying transform code

Posted: Sun Sep 26, 2021 9:48 pm
by lindsay-jb
Hey, so I made a specific transform that acts the type of transition I want to use for my displayables. The problem is, whenever I take the sprites off the screen, I'm finding that I have to type pause 0.3 every single time I take a sprite off the screen to give the transform time to play. So you can see, let me show you an example of what the coding looks like:

Code: Select all

    show amalia at inright with dis

    amalia_s "So, are we looking for anything in particular?" with dis

    show amalia at outright
    pause 0.3
    show rowan at inleft with dis

    rowan_s "I think I'll know it when I see it." with dis

    show rowan at outleft
    pause 0.3
    show amalia at inright with dis

    amalia_s "That's a little ominous coming from you." with dis

    show amalia at outright
    pause 0.3
    show rowan at inleft with dis

    rowan_s "Just go read a book or something." with dis

    show rowan at outleft
    pause 0.3


And here are my transform definitions:

Code: Select all

transform inleft():
    offscreenleft
    zoom 0.1
    anchor (1.0, 0.5)
    pos (0.0, 0.5)
    ease 0.15 zoom 0.3 align (0.0, 0.75)
    ease 0.1 zoom 1.0 align (0.0, 1.0)

transform inright():
    offscreenright
    zoom 0.1
    anchor (0.0, 0.5)
    pos (1.0, 0.5)
    ease 0.15 zoom 0.3 align (0.8, 0.75)
    ease 0.1 zoom 1.0 align (0.6, 1.0)

transform outleft():
    zoom 1.0
    ease 0.25 offscreenleft zoom 0.1

transform outright():
    zoom 1.0
    ease 0.25 offscreenright zoom 0.1
It's suuuuper cumbersome. The biggest thing I'd like to be able to get rid of is the pause 0.3. However, bonus points if I could add the dis transition (which is short for dissolve) to part of the transform as well, and BONUS bonus points if I could maybe even make an animation for each sprite or something? and every time I say "show amalia" it automatically shows her with the inright transform and every time I say "hide amalia" or "show amalia out" or something, it shows her with the outright transition.

Anyway, if someone could help me shorten this a little bit and make it more automated, that would be great. Idk if I can stand coding a whole book with this cumbersome mess lol

Re: Simplifying transform code

Posted: Tue Sep 28, 2021 7:16 pm
by hell_oh_world
use functions.
https://www.renpy.org/doc/html/statemen ... lents.html

Code: Select all

init python:
  def show(name):
    ats = []
    if name == "amelia": ats.append(outright)
    elif name == "rowan": ats.append(outleft)
    
    renpy.show(name, at_list=ats)
    renpy.pause(0.3)

label start:
  $ show("amelia")
  "amelia..."
  $ show("rowan")
  "rowan..."

Re: Simplifying transform code

Posted: Wed Sep 29, 2021 11:54 am
by lindsay-jb
Thank you! This code was what I needed and I was able to adapt it to my purposes. Thanks so much again!