How do I show & hide text within a screen using an action?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How do I show & hide text within a screen using an action?

#1 Post by henvu50 »

Code: Select all

screen testWindow:
   text "Text 1"
   text "Text 2"
   
   imagebutton:
      idle "images/button5.png"
      #onclick
      # hide TEXT 2
   
When the image button is clicked, how do I hide "Text 2" using action?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: How do I show & hide text within a screen using an action?

#2 Post by Remix »

Code: Select all

screen testWindow():
    default local_screen_var = True
    vbox:
        text "Text 1"
        if local_screen_var:
            text "Text 2"
       
        textbutton "Show/Hide":
            action ToggleScreenVariable( "local_screen_var" )

label start:

    show screen testWindow
Other Actions here -> https://www.renpy.org/dev-doc/html/screen_actions.html
Frameworks & Scriptlets:

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How do I show & hide text within a screen using an action?

#3 Post by henvu50 »

Thank you

Post Reply

Who is online

Users browsing this forum: No registered users