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?
How to change the absolute position of a GUI element
-
- Posts: 340
- Joined: Wed Sep 28, 2005 4:38 pm
- Location: Canada, Eh!
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
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
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:
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...
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));
i think you should try it this way... maybe it works...
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Audiere Sounds-API v1.9.3
Current Project: KoulesXD