[SOLVED]Using transitions when hiding screens from a button image

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
Xenubin
Newbie
Posts: 15
Joined: Tue Aug 11, 2020 7:04 pm
Completed: 5
Projects: Lytelove, Titan Arum, Carnival of Shadows
Github: xenubinx
itch: xenubinstudios
Contact:

[SOLVED]Using transitions when hiding screens from a button image

#1 Post by Xenubin »

Hi! back again to be annoying

ages ago I finalllyyy got the music player working in my game, and now im finally working on some updates now that the demo is out.
TLDR I added a button to hide it (bc why have it on the screen the whole time) and a button to show it back up in another place


but I think the sudden disappearance is slightly jarring. I'd love to be able to add a transition to it when it hides so that I can pretend its like a window minimizing
that said I think I just want to use the renpy dissolve transition for it


Im horrible at organizing these posts but i essentially just want the screen to dissolve off when it hides


here's some spaghetti

Code: Select all

            imagebutton auto "gui/mp_hide_%s.png":
                xpos 455
                ypos 3
                focus_mask True
                action Function(renpy.hide_screen, "textmiddle")


And here's the whole screen itself if it helps

Code: Select all

screen textmiddle:

    default music_is_playing = False #i know this seems contradictory but this is just the default states, plus i triggered music to start once we enter into game immediately
    default music_is_paused = False
    
    drag:
        draggable True
        droppable False
        drag_raise True
        pos(1375,50)
        drag_offscreen (200, 200)

        frame:
            background None
            
            image "gui/musicplayer.png" 

            $ playing = renpy.music.get_playing("music")
            if playing is not None:
                transclude
                $ track_name = track[1]
                $ track_creator = track[2]
            
                text "{size=25}Now Playing...{/size}" yalign 0.01 xalign 0.01
                text "[song_name] - [song_description]" yalign 0.05 xalign 0.01
                
            else:
                text "No Music Playing" xalign 0.5 yalign 0.5
            ##below are the buttons and how we set them up to work with the music rooM! not sure if its correct or not, but it works and thats all i care about at this point
            imagebutton auto "gui/mp_hide_%s.png":
                xpos 455
                ypos 3
                focus_mask True
                action Function(renpy.hide_screen, "textmiddle")

            imagebutton auto "gui/mm_pause_%s.png":
                xpos 128
                ypos 85 
                focus_mask True #focus mask makes it hoverable, its just image buttons like ud see on the  main menu of games!
                action [SetVariable('current_track', renpy.music.get_playing()),
                        mr.TogglePause()]
                hovered [ Play("sound", "audio/click.wav") ]  #plays this sound when clicked

            imagebutton auto "gui/mp_play_%s.png":
                xpos 216 
                ypos 85 
                focus_mask True  
                action [SetVariable('current_track', renpy.music.get_playing()),
                        mr.TogglePause()]
                hovered [ Play("sound", "audio/click.wav") ]
            
            imagebutton auto "gui/mp_skip_%s.png" xpos 309 ypos 85 focus_mask True action mr.Next() hovered [ Play("sound", "audio/click.wav") ]

Xenubin
Newbie
Posts: 15
Joined: Tue Aug 11, 2020 7:04 pm
Completed: 5
Projects: Lytelove, Titan Arum, Carnival of Shadows
Github: xenubinx
itch: xenubinstudios
Contact:

Re: [SOLVED]Using transitions when hiding screens from a button image

#2 Post by Xenubin »

Figured it out!!

i set up a custom transition

Code: Select all

transform musicTrans:
    on show:
        alpha 0.0
        ease 0.5 alpha 1.0
    on hide:
        ease 0.5 alpha 0.0

and then added "at musicTrans" under the drag portion

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]