Hello! Not sure why this is happening…is it a bug or am I doing something very silly?
I notice when I do this:
[java]
Label l = new Label(GUIManager.getScreen(), thought, new Vector2f(0, 0), new Vector2f(450, 50));
l.setText(thought);
l.setFontSize(35);
l.setX(getDrawPointX(thought));
l.setY(getDrawPointY(thoughts.size()));
GUIManager.addElement(l);[/java]
The Y coordinate is calculated depending on where the label is in the list so when there is 1 item in the list getDrawPointY returns 5. However, the label is not drawn to ‘5’, it is drawn to ‘505’.
However, if I do this:
Label l = new Label(GUIManager.getScreen(), thought, new Vector2f(0, 0), new Vector2f(450, 50));
l.setText(thought);
l.setFontSize(35);
GUIManager.addElement(l)
l.setX(getDrawPointX(thought));
l.setY(getDrawPointY(thoughts.size()));
@avpeacock said:
Hello! Not sure why this is happening...is it a bug or am I doing something very silly?
I notice when I do this:
[java]
Label l = new Label(GUIManager.getScreen(), thought, new Vector2f(0, 0), new Vector2f(450, 50));
l.setText(thought);
l.setFontSize(35);
l.setX(getDrawPointX(thought));
l.setY(getDrawPointY(thoughts.size()));
GUIManager.addElement(l);[/java]
The Y coordinate is calculated depending on where the label is in the list so when there is 1 item in the list getDrawPointY returns 5. However, the label is not drawn to ‘5’, it is drawn to ‘505’.
However, if I do this:
Label l = new Label(GUIManager.getScreen(), thought, new Vector2f(0, 0), new Vector2f(450, 50));
l.setText(thought);
l.setFontSize(35);
GUIManager.addElement(l)
l.setX(getDrawPointX(thought));
l.setY(getDrawPointY(thoughts.size()));
It works fine!
This happens with all elements. I made an odd decision to flip the y coord when initially adding an element to it’s parent to make initial layouts a bit easier (as y is normally botton to top) when being put together. However, this proved tobe an ABSOLUTE NIGHTMARE trying to maintain the flipped y, so left it alone from that point on.
I suggest continuing with adding placement prior to adding to a parent element.
There is the option of removing the element from it’s parent, setting the placement and then adding it again. (this should flip the y around again). However, you’ll want to keep in mind… if you use e.setY(e.getY()+somenumber) you could potentially bounce the object back and forth from top to bottom over and over. Just a side note =)