A transform callback would be cool

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
ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

A transform callback would be cool

#1 Post by ChesStrategy »

Been messing with transforms again, and I'm sort of stuck... see the code below

Code: Select all

renpy.show( 'something', at_list=[ place( 0, 0 ), slide( 200, 1.0 ), slide( -200, 1.0, start_offset=200 ) ] )
The goal was to place something at xpos, ypos of (0,0) and then slide something by an xoffset of 200 for 1 second, then see it slide back from xoffset 200 to an xoffset -200. However, only the last transform seems to be 'performed'.

Maybe I'm tired and may be misunderstanding the internals of renpy again; but after putting in a lot of debugging in my code; I think all of the transforms do run simultaneously (a thread for each maybe?), but are immediately canceled or something by the next one in the list.

Doing this solves the issue:

Code: Select all

renpy.show( 'something', at_list=[ place( 0, 0 ) ] )
renpy.pause( 1.0 )
renpy.show( 'something', at_list=[ slide( 200, 1.0 ) ] ) 
renpy.pause( 1.0 )
renpy.show( 'something', at_list=[ slide( -200, 1.0, start_offset=200 ) ] )
however, this means I can only control 'timings' for one 'something' at a time.

I cannot do something like this (see below); I cannot animate objects B and C at the same time and have them transform themselves in an order/sequence with different timings...
place (object B), wait 2 seconds, slide 200, wait 3 seconds, slide -200
place (object C), wait 3 seconds, slide 400, wait 2 seconds, slide -400, wait 5 seconds, slide 600


if the timings were the same; then I could do:

Code: Select all

renpy.show( 'B', at_list=[ place( 0, 0 ) ] )
renpy.show( 'C', at_list=[ place( 0, 0 ) ] )
renpy.pause( 1.0 )
renpy.show( 'B', at_list=[ slide( 200, 1.0 ) ] )
renpy.show( 'C', at_list=[ slide( 400, 1.0 ) ] )  
renpy.pause( 1.0 )
renpy.show( 'B', at_list=[ slide( -200, 1.0, start_offset=200 ) ] )
renpy.show( 'B', at_list=[ slide( -400, 1.0, start_offset=400 ) ] )
I think it would help if we can somehow associate a callback to each transform, so that I can time/call each transform in a chain. Or Is there another way I can achieve this?

Regards,
Ches

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: A transform callback would be cool

#2 Post by PyTom »

Isn't this pretty much what ATL is for?
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
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: A transform callback would be cool

#3 Post by nyaatrap »

You can include other transforms in a transform to make a composite transform. You can also include functions in a transform (that should perform as callback).

Counter Arts
Miko-Class Veteran
Posts: 649
Joined: Fri Dec 16, 2005 5:21 pm
Completed: Fading Hearts, Infinite Game Works
Projects: Don't Save the World
Organization: Sakura River
Location: Canada
Contact:

Re: A transform callback would be cool

#4 Post by Counter Arts »

What about this for your two display objects at the same time?

Code: Select all

transform transformB:
  pos (0,0)
  time 2.0
  linear 1.0 xpos 200
  time 3.0
  linear 1.0 xpos 0 # assuming slide does something by relative positioning to previous position

transform transformC:
  pos (0,0)
  time 3.0
  linear 1.0 xpos 400
  time 2.0
  linear 1.0 xpos 0
  time 5.0
  linear 1.0 xpos 600

show somethingB at transformB
show somethingC at transformC
  
Edit: I'm guessing you might be used to old school style of animation programming? Take a look at this page for ren'py.

http://www.renpy.org/doc/html/trans_trans_python.html
Fading Hearts is RELEASED
http://www.sakurariver.ca

Post Reply

Who is online

Users browsing this forum: Google [Bot], peach_light