Exit animation on transient screens

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
Ikaros_OwO
Newbie
Posts: 1
Joined: Wed Dec 27, 2023 5:57 am
itch: python
Contact:

Exit animation on transient screens

#1 Post by Ikaros_OwO »

Hi, I'm trying to make a phone mechanic that whenever you press a button, a phone will slide out from the right side of the screen. After the user is done interacting with the phone, they can just press outside it and the phone will slide away. Below is my current implementation:

Code: Select all

init python:
	def show_phone():
		renpy.transition(moveinright)
        	renpy.show_screen("phone", _transient=True)
        	
screen screen_ui():
	textbutton "Show phone" Function(show_phone)
The problem with it is that while clicking on the 'Show phone' button slides the phone inside the screen as intended, clicking outside of it to quit the screen will:
- First click do nothing
- Second click dissolve the phone screen and roll forward one dialogue

While the intended behavior is:
- First click slide the phone screen outside where it came from
- Second click and onward progress with the dialogue as usual

What change should I make to the function for it to behave as intended? Or am I approaching this in the wrong way?

Any feedback would be appreciated.
Also if it helps: The "phone" screen implemented is from Better EMR Phone.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Exit animation on transient screens

#2 Post by m_from_space »

Ikaros_OwO wrote: Wed Dec 27, 2023 6:18 am The problem with it is that while clicking on the 'Show phone' button slides the phone inside the screen as intended, clicking outside of it to quit the screen will:
- First click do nothing
- Second click dissolve the phone screen and roll forward one dialogue

While the intended behavior is:
- First click slide the phone screen outside where it came from
- Second click and onward progress with the dialogue as usual

What change should I make to the function for it to behave as intended? Or am I approaching this in the wrong way?
If you don't want user clicks to interact with anything other than the current screen, you have to set "modal" to True. And if you want any click inside the screen trigger an action (as long as the user is not clicking anything specific I mean), you can just use a "dismiss" object.

Code: Select all

screen phone():
    # makes sure that no other screen can be interacted with while this one is shown
    modal True
    
    # hides the screen if the player clicks anything but a button
    dismiss action Hide()
    
    # the rest of the screen
    add "phone.jpg"
    textbutton "Call Eileen" action NullAction()
No of course you want your phone to slide away, which is easy, just do the opposite of sliding it in as part of the "dismiss".

Post Reply

Who is online

Users browsing this forum: No registered users