[SOLVED] Positioning images with an Absolute value

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
theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

[SOLVED] Positioning images with an Absolute value

#1 Post 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.
Last edited by theyeeguy on Sat Sep 25, 2021 3:36 pm, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3784
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Positioning images with an Absolute value

#2 Post by Imperf3kt »

Give your x.anchor and y.anchor a .0 so you aren't mixing integers and floats
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Positioning images with an Absolute value

#3 Post 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().

theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

Re: Positioning images with an Absolute value

#4 Post 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.

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Positioning images with an Absolute value

#5 Post 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 :oops:

P.S.: it's about https://www.renpy.org/doc/html/style_pr ... rty-values
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

Re: Positioning images with an Absolute value

#6 Post 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 :oops:

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.

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: [SOLVED] Positioning images with an Absolute value

#7 Post by drKlauz »

Glad it helped, good luck with your game :D
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

Post Reply

Who is online

Users browsing this forum: No registered users