Help with placement of an image

Hi forum,

I have been using jmonkey to create an FPS, so i can learn how to create more complex games. I have an image of a gun i would like to use to learn how to position 2d images in the guiNode. The code I am using to display the gun looks like this:



Picture gun = new Picture(“HUD Picture”);

gun.setImage(assetManager, “Interface/ak.png”, true);

gun.setWidth(settings.getWidth()/2);

gun.setHeight(settings.getHeight()/2);

gun.setPosition(settings.getWidth()/4, settings.getHeight()/4);

guiNode.attachChild(gun);



When i run the game the gun appears in the middle of the screen near the crosshairs. I would like the gun to appear at the bottom of the screen. I have tried playing around with the getWidth and getHeight values but i cannot choose the correct ones for me to posiiton the gun in the bottom right corner like what i want. Could somebody please help me with the placement and perhaps i could learn a thing or two :wink:

try:



[java]gun.setPosition(settings.getWidth()-gun.getWidth(), 0);[/java]

I get a red wiggly line under the getWidth part of -gun.getWidth()

@javagame said:
I get a red wiggly line under the getWidth part of -gun.getWidth()


that means your graphics card is fried, you will need to get a new one

Sorry, I didn’t realise you couldn’t call getWidth() on Picture…



just use :

[java]gun.setPosition(settings.getWidth()-settings.getWidth()/2, 0);[/java]

Thank you very very much! Could you please document to me what the individual parts of this line do? So I have a better understanding of jmonkey.

No problems.



The best thing for you to do right now would be to carefully go through all the tutorials, starting with Hello Simple Application.



Once you have done all those you should have no problems ‘document to me what the individual parts of this line do’ :slight_smile:

:slight_smile: thank you