Custom Transition in Python

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
User avatar
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

Custom Transition in Python

#1 Post by Lord Hisu »

I'm trying to move a custom displayable with keyboard input using MoveTransition in Python.
I already know how to move the displayable without the transition, by changing the blit position. I have a parent class and two children, all displayables. Here's my render method of the parent. Please point out if I'm doing something wrong with the width and height arguments, I'm not sure yet of what area I should pass to the children, since I failed to notice anything changing at all.

Code: Select all

def render(self, width, height, st, at):
            canvas = renpy.Render(width, height)
            
            # This method updates the children with the consequences of the keyboard input,
            # changing their positions.
            self.check_movement()
            
            render_map = renpy.render(self.map_base, width, height, st, at)
            render_char = renpy.render(self.char, width, height, st, at)
            canvas.blit(render_map, (0,0))
            canvas.blit(render_char, (0,0))
            
            renpy.redraw(self, 0)
            return canvas
What I want is not to alter the positions of the children directly, but to apply a MoveTransition that move the children from A to B given the delay.
I can't quite understand this part of the documentation, what I do understand is that I need to renpy.render a displayable, and blit that render to the parent's render, that needs to be returned. I successfully applied Transforms too, but the transition part is still kind of confusing.

Can someone show me a simple working render method that applies a MoveTransition?
And if possible, explain step by step what is happening, what is returning what, and so on.

Thank you in advance!

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Custom Transition in Python

#2 Post by PyTom »

You don't really want to use MoveTransition. What you want to do here is to use the information you have to blit render_char at a different offset.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

Re: Custom Transition in Python

#3 Post by Lord Hisu »

PyTom wrote: Sun Feb 18, 2018 1:48 am You don't really want to use MoveTransition. What you want to do here is to use the information you have to blit render_char at a different offset.
That's what I want, but I thought a transition would do that for me.
I could do that manually, yes, but in this case I think I'm misunderstanding transitions.
Can you please clarify that for me?

Post Reply

Who is online

Users browsing this forum: Bing [Bot], simple_human