Question on 2d coordinates(placement of image

Hallo,
I’m trying to do a rts-style minimap and in the process I stumbled over one issue I couldn’t solve:

I have some problems with the placing of the OnscreenImages. I guess the pos you specify for the OnscreenImage is given in aspect2d coordinates, right?
Now if I try to place an Image in the lower left corner by using the following coordinates, I still can’t see the whole image(only slightly displaced in both directions):

x=-base.getAspectRatio()+minimapSizeX*0.5/(base.win.getXSize()*0.5)
z=-1.0+minimapSizeY*0.5/(base.win.getYSize()*0.5)

How can I fix that?

  1. I don’t know what commands you are using to create your OnscreenImage, but if you are loading an image using the low-level PNMImage library, it is up to you to enable transparency on the resulting OnscreenImage object. You can do this with:
myOnscreenImage.setTransparency(TransparencyAttrib.MAlpha)
  1. An easier way to locate an object in the lower-left corner is to parent it to base.a2dBottomLeft instead of the default, aspect2d. You can do this with:
myOnscreenImage.reparentTo(base.a2dBottomLeft)

or specify parent = base.a2dBottomLeft in the OnscreenImage constructor.

David

Thanks, drwr.
I solved number 1 already.
On number 2:
I’m trying to place the image in such a way that it’s lower left corner is in the lower left corner of the screen. By reparenting to the lower left corner I would still have to do calculations similar to my first post.
But those don’t seem to be right.

No you don’t have to.
[DirectGUI or nodepath alignment)

Thanks, ynjh_jo. Your code solved it. :slight_smile: