Page 1 of 1
[SOLVED] Positioning images with an Absolute value
Posted: Fri Sep 24, 2021 4:31 pm
by theyeeguy
Greetings everyone. I've run into a problem where I tried to position an image with its xpos/ypos as an absolute value. Shown below is the code of the image.
Code: Select all
image bg2-desert:
"backgrounds2/desert-2.png"
xanchor 0
yanchor 0
xpos absolute(0.0)
ypos absolute(658.3458)
Running said code results in an "
AttributeError: 'module' object has no attribute 'absolute'" error whenever the script reaches the
show bg2-desert line. I have tried replacing
absolute(x.x) with
renpy.absolute(x.x) or even simply put in 658.35 as the ypos but to no avail. Either it displays the error or the image does not display at all. I'd very much appreciate it if someone could help me out.
Re: Positioning images with an Absolute value
Posted: Fri Sep 24, 2021 5:05 pm
by Imperf3kt
Give your x.anchor and y.anchor a .0 so you aren't mixing integers and floats
Re: Positioning images with an Absolute value
Posted: Fri Sep 24, 2021 7:18 pm
by hell_oh_world
Adding to what
Imperf3kt said, integers as values in properties mean you're positioning it by pixels while floats as values mean you're positioning it relative to the parent.
https://www.renpy.org/doc/html/style_pr ... rty-values
Also, you're probably talking about the built-in function
abs().
Re: Positioning images with an Absolute value
Posted: Sat Sep 25, 2021 4:23 am
by theyeeguy
What about when I'm positioning it as an absolute type? Is there any way to specify that I'm trying to position my image 658.3458 subpixel in the y axis? I might be understanding it wrong but that's what I got from reading this in the position section.
absolute (like absolute(100.25))
An absolute number is interpreted as the number of pixels from the left or top side of the screen, when using subpixel-precise rendering.
I have also tried removing the
xanchor and
yanchor while changing
absolute(x.xx) to abs
(x.xx) so as to avoid any conflict errors. Error disappeared but the image is not rendering at all.
Re: Positioning images with an Absolute value
Posted: Sat Sep 25, 2021 12:16 pm
by drKlauz
This worked for me
Code: Select all
image test:
"bg_001_01"
anchor (0,0)
xpos absolute(100.5)
ypos absolute(0.0)
label start:
show test
"test"
return
Check if you have absolute replaced somewhere in script maybe. Another option, delete lines with absolute and type them again, maybe some weird character got there somehow, once spent hour or so trying to debug error while it was just different language symbol camping inside english word
P.S.: it's about
https://www.renpy.org/doc/html/style_pr ... rty-values
Re: Positioning images with an Absolute value
Posted: Sat Sep 25, 2021 3:35 pm
by theyeeguy
drKlauz wrote: ↑Sat Sep 25, 2021 12:16 pm
This worked for me
Code: Select all
image test:
"bg_001_01"
anchor (0,0)
xpos absolute(100.5)
ypos absolute(0.0)
label start:
show test
"test"
return
Check if you have absolute replaced somewhere in script maybe. Another option, delete lines with absolute and type them again, maybe some weird character got there somehow, once spent hour or so trying to debug error while it was just different language symbol camping inside english word
P.S.: it's about
https://www.renpy.org/doc/html/style_pr ... rty-values
Thank you very much! This also worked for me. I was actually beginning to contemplate on trying to design my drafts around int x and y positions (which would lead to some problems down the road) so I just want you to know you're a godsend. Cheers!
I'm guessing it was the
anchor (0,0) that did it, which is odd because my initial code had each anchors in int, and subsequent debugging had me remove it altogether. Both should technically have the default int 0 as its anchor values.
Re: [SOLVED] Positioning images with an Absolute value
Posted: Sun Sep 26, 2021 8:11 am
by drKlauz
Glad it helped, good luck with your game