Simplifying transform code

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
lindsay-jb
Regular
Posts: 68
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Simplifying transform code

#1 Post 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

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Simplifying transform code

#2 Post 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..."

lindsay-jb
Regular
Posts: 68
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Re: Simplifying transform code

#3 Post 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!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]