[solved]properties 'anchor' and 'align' conflict with each other?

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
User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

[solved]properties 'anchor' and 'align' conflict with each other?

#1 Post by Kia »

I've got
properties 'anchor' and 'align' conflict with each other
While trying to

Code: Select all

    show image "gui/window_icon.png":
        align (0.5,0.5) anchor (0.0, 0.0)
It really caught me off guard.
Did I miss something in the changelog? Is there something new added instead of combining those two?
Last edited by Kia on Mon Jun 26, 2023 2:15 pm, edited 1 time in total.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#2 Post by _ticlock_ »

Kia wrote: Sun Jun 25, 2023 1:46 pm

Code: Select all

align (0.5,0.5) anchor (0.0, 0.0)
I am not sure when they started to conflict.

Align is supposed to set both pos and anchor, so they should conflict with each other. I believe documentation never explained what should happen if you combine them together. That is probably why the changelog may not explicitly say it.

According to changelog 8.1 / 7.6:
Ren'Py will now produce errors when a screen sets two conflicting properties, like align, and xalign. Previously, the behavior of this was undefined.
It probably should not affect existing projects:
The new config.check_conflicting_properties variable, which is disabled in existing games but enabled in newly created games, enables you to check for conflicting style or transform properties being set concurrently.

User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#3 Post by Kia »

Align and pos conflicting makes sense, there's never any reason to use them together either, but align and anchor are bread and butter. There are many scenarios that we need to align a specific corner of a displayable to somewhere, and that's impossible without using both of them. Should we report this as a but?

philat
Eileen-Class Veteran
Posts: 1920
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#4 Post by philat »

I believe the point is that you should be using pos and anchor instead of align and anchor, because align is setting anchor and pos together (e.g., xalign 1.0 sets xanchor to 1.0 and xpos to 1.0).

User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#5 Post by Kia »

I see...
I've knew that pos can take floats, but I've always seen it as unnecessary complication.
Before, align would set the anchor if not provided otherwise, but now, it's like giving a spoon to kids to eat soup with, but forcing them to switch to knife and fork for those small chunks of potato in it, they fit in the spoon fine.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#6 Post by _ticlock_ »

Kia wrote: Mon Jun 26, 2023 2:18 am I see...
I've knew that pos can take floats, but I've always seen it as unnecessary complication.
Before, align would set the anchor if not provided otherwise, but now, it's like giving a spoon to kids to eat soup with, but forcing them to switch to knife and fork for those small chunks of potato in it, they fit in the spoon fine.
I like the analogy, but I believe the confusion appeared because, previously, some of the renpy default screens used conflicting properties together.

We should either set pos and anchor pos (0.5,0.5) anchor (0.0, 0.0) or if they have the same value, we can use align (0.0,0.0). There are default values for pos and anchor if we don't specify any of these properties.

Conflicting properties may result in different behavior in some cases. For example https://github.com/renpy/renpy/issues/3702 (the example is about pos and align but the same is true for align and anchor)

User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: properties 'anchor' and 'align' conflict with each other?

#7 Post by Kia »

In my opinion, keeping the pixel positioning for pos and percent positioning to align made much more sense, and makes for a code that's easier to read. But I should stop being a perfectionist, these small flaws are everywhere.
Thank you _ticlock_ ^^

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2411
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: [solved]properties 'anchor' and 'align' conflict with each other?

#8 Post by Ocelot »

pos, anchor and align all accemp both fractional or absolute values, and it is really useful sometimes.

(xanchor 0.0 xpos 0.5) and (xanchor 1.0 xpos 0.5) will position two images side-by-side at the center of the screen. Something like (anchor 12, 7) is useful for custom pointers, so you could position it exactly where you need.

While align works funny with absolute values (visually it image will remain in the top left corner), but they might be useful in conjunction with ATL animations.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: No registered users