Draggable Screen always return to initial positionning

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
sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Draggable Screen always return to initial positionning

#1 Post by sculpteur »

Hello,

I have a prefeclty draggable working screen.
Each time I calling it, it appear to the initial position I gave him, thats mean at xpos 1250 and ypos 100.
Even if the player move it previously to an other location.
So I would like it too show up at the same position the player leave it before. I don't know if I'm really understandable sorry.

I try to just suppress the line with xpos and ypos but this is still not working, my screen is simply poping at the top left corner of my physical screen each time, regardless of where the player position it before.

I'm pretty sure this is a really commun mistake newbies does when they are messing with draggable stuff for the first time so I tought I could just ask here on the forum cause one of you will probably saw immediatly how to fix this behaviour. I could problably manage to do it myself after several hours (days?) but I'm too scared to mess up the code of my recently working draggable screen !

Code: Select all

 
 
 screen minigame_info_screen():
    $ tooltip2 = Tooltip("[character_name] is [variable_mood].")
    drag:
        draggable True
        drag_handle (0, 0, 545, 239)
        xpos 1250 ypos 100 # PRETTY SURE THIS IS THE LINE WERE I FUCKED UP
        
        frame:
            style "variables_nbr"
            background "gui/image_MiniGame.png"
            top_padding 20
            xysize (545, 225)

            text "[variable_A]":
                style "variables_nbr"
                size 40
                xpos 90 ypos 80
                
            mousearea:
                area (9, 10, 69, 71)
                hovered tooltip2.action("{color=#66cc00}TEXT:{/color} Text")
            text "" pos (9, 10) tooltip
            
I don't know if it could be related, but in my code I use this show the previous screen ("minigame_info_screen") :

Code: Select all

screen main_minigame:
    modal True
    imagemap:
        ground "imageA"
        hover "imageB"
        alpha False
        hotspot (256, 843, 268, 71) action Jump("Label_A")
        hotspot (252, 929, 284, 78) action Jump("Label_B")

    use minigame_info_screen
    add "gui/Interface_Indicator_Interaction.png"
    use quick_screen_keys_input
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Draggable Screen always return to initial positionning

#2 Post by sculpteur »

Any Idea ?
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Draggable Screen always return to initial positionning

#3 Post by Alex »

sculpteur wrote: Mon Aug 30, 2021 6:37 pm ...

Code: Select all

 
screen minigame_info_screen():
    $ tooltip2 = Tooltip("[character_name] is [variable_mood].")
    drag:
        draggable True
        drag_handle (0, 0, 545, 239)
        xpos 1250 ypos 100 # PRETTY SURE THIS IS THE LINE WERE I FUCKED UP
...
Yes, you've set the position for draggable, so every time you show this screen the draggable appears at that position.
Try to set this position via variable, and make a function, that will update the value of this variable after draggable was dragged.
This should help - viewtopic.php?f=8&t=62944#p545717

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Draggable Screen always return to initial positionning

#4 Post by sculpteur »

Thank you ! I manage to use your example and this is working just fine.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

Post Reply

Who is online

Users browsing this forum: No registered users