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.
transform scaleup():
xpos 50
ypos 50
zoom 0.5
linear 1.1 zoom 0.8
screen showme():
add "images/cloud.png" at scaleup()
However that code will scale the image from the top left corner. I would like to scale out from the center of the image, like an explosion effect.
I also tried adding truecenter to the transform, which has the desired effect of scaling from center, but then the image is locked to the middle of the viewport. Any positional fields (xpos,ypos,xanchor,yanchor,xalign,yalign) I give it won't move my image to the location I want it in (xpos 50, ypos 50).
How can I scale up from the center image position, and also have it at a certain x,y coordinate?
transform scaleup():
xpos 50
ypos 50
zoom 0.5
linear 1.1 zoom 0.8
screen showme():
add "images/cloud.png" at scaleup()
However that code will scale the image from the top left corner. I would like to scale out from the center of the image, like an explosion effect.
I also tried adding truecenter to the transform, which has the desired effect of scaling from center, but then the image is locked to the middle of the viewport. Any positional fields (xpos,ypos,xanchor,yanchor,xalign,yalign) I give it won't move my image to the location I want it in (xpos 50, ypos 50).
How can I scale up from the center image position, and also have it at a certain x,y coordinate?
show cloud:
xpos int(200-(37*0.5))
ypos int(200-(75*0.5))
zoom 0.5
linear 1.1 xpos int(200-(37*0.8)) ypos int(200-(75*0.8)) zoom 0.8
The mid-point of the image is at 200, 200.
My image was 74x150,
37 and 75 is half of the width and height.
You need of course to adjust for the values of your image and the point you want to set the mid-point at.
Using the zoom value to adjust the xpos/ypos will keep the image's midpoint at the same position.
200x200 is the position the (top left corner of the) image is on the screen, not the image dimensions.
I'm not sure why you wouldn't use xalign 0.5 yalign 0.5 for this though
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Finishing the zoom at .8 rather than 1. complicates this somewhat, and the following implementation is extremely non-flexible. A better all round solution would be to (if possible) literally define pos (x, y) as the centre of the image (removing the need for the offsets), use anchor (.5, .5) and then add the zooms finishing at 1.0, since that would remove any need to know about the image size (from the transform) and avoid needing to duplicate the final zoom factor.
All that said, I believe what you're looking for can be achieved thus:
newbiemate wrote: ↑Fri Mar 08, 2019 2:23 pm
Can you help explain how you got 200x200? If your image is 75x150, and I want to put your image at x=50,y=50, how did you come up with the offset 200?
If my image is 400x600, and I want it at x=50,y=50, what would my offset be?
200x200 was just a random point I picked to test out the code on. I did not have enough information to calculate what would be the right numbers for you.
That point is the middle of the image, not the top left corner. The middle of the image is the only point of the image that will be fixed as the image scales up or down.
All of the corners will be moving.
When you say 50X50 I assume you are talking about the top left corner. If so that position will change throughout the scaling . So is it 50X50 at the start of the scaling or the end?
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
You can easily zoom an image from its center or from any of its corners, from the top or from the bottom of that image. Look here: https://www.renpy.org/doc/html/transfor ... transforms
You just include any of those default position transforms in your own transform. To zoom an image from its center, no matter what position it is on the screen: