as you know the "xanchor" changes with "xalign", this made me wonder what's the correct formula for calculating "xalign" of a dragged child using available information:
drag[0].x
drag[0].w
and config.screen_width
[solved]how can I calculate xalign using xpos and xsize?
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.
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.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
[solved]how can I calculate xalign using xpos and xsize?
Last edited by Kia on Tue Jan 22, 2019 2:35 am, edited 1 time in total.
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: how can I calculate xalign using xpos and xsize?
Code: Select all
cal_xalign_value = drag[0].x/config.screen_width
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: how can I calculate xalign using xpos and xsize?
unfortunately this doesn't take into account the width of the drag's child and the change in the xanchor when drag is moved towards the left side of screen. only works if the width of child is zero.DragoonHP wrote: ↑Mon Jan 21, 2019 11:53 amThis should give you an xalign value in respect to the entire screen.Code: Select all
cal_xalign_value = drag[0].x/config.screen_width
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: how can I calculate xalign using xpos and xsize?
Can you tell me what you are trying to do? I'm not sure how width of a child affects xalign
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: how can I calculate xalign using xpos and xsize?
thank you ^_^Per K Grok wrote: ↑Tue Jan 22, 2019 1:58 am I think this should work
xalign = xpos / (screenwidth - xsize)
it's was as simple as putting two and two together, yet I failed to see it for hours of trial and error.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: how can I calculate xalign using xpos and xsize?
while using xalign, it's necessary that the anchor point of the child to be aligned along the child's width. for example:
xalign 1.0 causes the xanchor to be set to 1.0 and the child to be aligned by it's right side instead of the usual left side.
and xalign 0.5 sets xanchor to 0.5 and align the child by it's center to keep the object at the center.
that's why we have to consider the child's width in calculation, DragoonHP gave me the solution.
Who is online
Users browsing this forum: Ahrefs [Bot]