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.
Hi, this might be a simple problem to solve but I'm having some trouble. Basically I want my picture to be zoomed out from the CENTER of its position not from the LEFT upper corner as it is default. I was searching some documentation but it seems like it doesn't work or maybe I'm using it incorrectly?
Nero wrote: ↑Mon Jun 15, 2020 11:29 pm
Hi, this might be a simple problem to solve but I'm having some trouble. Basically I want my picture to be zoomed out from the CENTER of its position not from the LEFT upper corner as it is default. I was searching some documentation but it seems like it doesn't work or maybe I'm using it incorrectly?
One way of doing this is to use xpos and ypos to position the image and as you zoom the images size you move the xpos and ypos at the same time using the zoom value.
In this example I have a sprite with the size 48x90. Since you want to have the position fixed to the center we will use half of those values, 24 and 45
show bub15:
pos (200-24 ,200-45) ## center positioned at 200, 200
zoom 1.0
ease 3.0 zoom 1.5 xpos int(200 - (24*1.5)) ypos int(200 - (45*1.5)) ## center always positioned at 200, 200 using half of the sprites width and height at any time during the movement. Since a position in pixels is a whole number I transform the number for xpos and ypos from a float to an integer.
Using truecenter sets the align property to (0.5,0.5) which in turn sets both anchor and pos to the same value.
Having the image anchored at 0.5,0.5 is exactly what you want.
The only way I could see this failing is if you were showing it inside another container that was aligned differently... such as a frame in a screen....
Sub-note: I would advise adding subpixel True to your transform (for any zoom or rotate)