xpos
and
ypos
are absolute positions.
The easiest way I've found to get "close enough" is to start your game, go into the Developer Menu (shift+D) then choose "Image Location Picker"... scroll down the list of images used by the game and find a fullscreen background image used by your game. It will load the image (hopefully fullscreen) and display it. In addition to your image, there will now also a box in the bottom left corner showing the current mouse position. Move the mouse about to where you want the top left corner of your UI element to be and write down the mouse coordinates. You can use these as your
xpos
and
ypos
. It probably won't be perfect first time, but it should close enough for you to start the game with your new code and keep moving things little by little until you are happy with the positioning.
Another handy way of doing that is the automatic source code reload RenPy can use in developer mode. Basically, once your game is running you can press (shift+R). Now if you change the source code and save... RenPy will notice the datetime/filesize has changed on the source code and reload the game using the new code. It's a great way to make small changes and see them almost immediately without having to quit and reload the game over and over. Even better if you have two monitors or enough screen area to be able to have both the game and the source code editor open and visible at the same time.
Now personally, I wouldn't do that. I'd load the background image into something like Photoshop or
You must be registered to see the links
(
free) and position things on multiple layers until I'm happy with how everything looks. Then I'd zoom in and use the editor's UI side rulers in pixels to figure out the absolute positioning.
xalign
and
yalign
are a little more complex.
xalign=0 will align the left hand side of an image against the left hand edge of the screen.
xalign=1 will align the right hand side of an image against the right hand edge of the screen.
... and everything in between. 0.5 is dead center. Same with yalign, except it's top and bottom instead.
The headache part (at least in my case) is that the image being displayed is also a certain size too.
xalign=0.25
might seem at first glance like it would put something 25% across the screen... and it sort of does - but not quite. It positions the left hand edge at ((screen size * 0.25) - (image size * 0.25))... Essentially positioning things so it's 25% to the right of the screen, but then adjusted it 25% to the left based on the image size. It's why 0.5 is has the image in the middle of the screen, with the middle of the image aligned to the middle of the screen rather than one of it's edges.
Personally, I'd prefer to use xalign and yalign for things like animations and xpos and ypos for UI elements. But they are both interchangeable as long as you are willing to do a bit of trial and error.