How to change the absolute position of a GUI element

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

How to change the absolute position of a GUI element

Post by Guest »

How can i change the absolute position of an element from the mouse position. There is only function setRelativePosition.
I want to change the position of the image according to the mouse position
When i press the image , and drag the mouse it change the image position
How?
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post by Conquistador »

In the 2D graphics tutorial, an image follows the mouse when it's moved. You can easily adapt that to your own needs.
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
Guest

Post by Guest »

i think u haven't understood my question properly
I m saying setting an absolute position not drawing an image.
i don't want to render each time drawing at different position by calling draw2DImage , plz read my ques first before answering
DaChief
Posts: 45
Joined: Tue Nov 01, 2005 9:02 am
Location: Switzerland

Post by DaChief »

If you set the guiRoot as the Parent of the Element, it should also work for the relativePosition that position2d<s32>(0,0) is on the top-left corner of the screen

for example if you add a window:

Code: Select all

IGUIWindow* window;

window =guienv->addWindow (rect<s32>(position2d<s32>(0,0),dimension2d<s32>(100,100)),false, L"A Window", guienv->getRootGUIElement(),-1);

window->setRelativePosition (rect<s32>(position2d<s32>(0,0),dimension2d<s32>(100,100));

in this case, the relativePosition is equal to the absolute one, because the GUIRoot is the hole screen... or something like that... or am i wrong with this ?
i think you should try it this way... maybe it works...
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Post Reply