Applying a transition/animation to a screen on button press

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
EJ107
Newbie
Posts: 19
Joined: Mon Feb 01, 2016 8:46 pm
Projects: Watching Time
Location: Birmingham, UK
Contact:

Applying a transition/animation to a screen on button press

#1 Post by EJ107 » Sat Nov 12, 2016 2:41 pm

Hello! It's been a while since I've had to ask for help here, but I'm struggling to get something working.

Essentially I have a small custom menu on my game that allows the user to enter a "time-travel" mode, where an overlay appears on the screen and they can rewind the game by clicking on certain buttons. This uses image buttons buttons and Ren'py's rollback function.

It all works fine, but I want it to look a little nicer than just having the overlay appear instantly out of nowhere and the scenes instantly change when you click to go back. Having the overlay fade in and being able to use a transition on my rollback calls so that the scenes slide across film-reel style would look a lot nicer, but I can't work out how to apply animations or transitions to a particular screen outside of the script.

If anybody has any ideas or knows of somewhere that already covers this I'd be very grateful!
Like my Avatar? Check out: https://www.patreon.com/lackadaisy?ty=h

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: Applying a transition/animation to a screen on button pr

#2 Post by PyTom » Sun Nov 13, 2016 1:56 am

You can use the With action. Something like:

[ Show("myscreen"), With(dissolve) ]
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
EJ107
Newbie
Posts: 19
Joined: Mon Feb 01, 2016 8:46 pm
Projects: Watching Time
Location: Birmingham, UK
Contact:

Re: Applying a transition/animation to a screen on button pr

#3 Post by EJ107 » Sun Nov 13, 2016 10:48 am

Thank you for responding. The way my code currently works doesn't actually create any new screens but places the objects I need in existing screens, because I could never get my own screens to display correctly.

An example of what I could never get working is below:

Code: Select all

screen test_screen():
    hbox:
        imagebutton xalign 0.5 yalign 0.5:
             idle Transform(im.Alpha("ui/text_box.png", 0.85), size=(500, 500))                   

...

init -2 python:
    class ShowScreen(Action):
        def __call__(self):
            Show("test_screen")        
The ShowScreen action is assigned to a button and runs when it is pressed, but the screen never actually appears.
Like my Avatar? Check out: https://www.patreon.com/lackadaisy?ty=h

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: Applying a transition/animation to a screen on button pr

#4 Post by PyTom » Mon Nov 14, 2016 1:07 am

If you want to create your own action that calls another action, you can do:

Code: Select all

init -2 python:
    class ShowScreen(Action):
        def __call__(self):
            renpy.run(Show("test_screen"))        
(It's probably better to just use Show directly, however.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
EJ107
Newbie
Posts: 19
Joined: Mon Feb 01, 2016 8:46 pm
Projects: Watching Time
Location: Birmingham, UK
Contact:

Re: Applying a transition/animation to a screen on button pr

#5 Post by EJ107 » Mon Nov 14, 2016 10:25 pm

Thanks a lot, I've got something that I'm pretty happy with now =)
Like my Avatar? Check out: https://www.patreon.com/lackadaisy?ty=h

Post Reply

Who is online

Users browsing this forum: No registered users