How do you get the screen x & y position of a displayable, by its ID?

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 you get the screen x & y position of a displayable, by its ID?

#1 Post by henvu50 »

How do you get the screen x & y position of a displayable, by its ID?

I'm looking for something super simple and effect, here's an example of code I'm looking for, to simply get a displayable's position info by id.

Code: Select all

screen test():
    button:
        id 'some_button_id_84'
        xpos 80   # 80/1920
        ypos 120    # 120/1080
        action NullAction()

label some_story_84:
    $ temp = renpy.get_placement('some_button_id_84')
    $ print(temp.xpos)  # not the alignment, but the actual x screen position
    $ print(temp.ypos)  # not the alignment, but the actual y screen position
get_placement() has no documentation or example of usage. https://www.renpy.org/doc/html/displayi ... _placement

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: How do you get the screen x & y position of a displayable, by its ID?

#2 Post by enaielei »

renpy.get_placement accepts a displayable as argument, use renpy.get_displayable to get the displayable then pass it as the argument.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]