AndiNo
21-08-2009 12:11:05
Hi! Now that MyGUI works for me I tried to implement some kind of crosshair for my game. I wanted to use a StaticImage that should be centered in the middle of the screen.
My code:
My layout file:
The problem is the widgets don't get centered. Only when I resize the Ogre window they get aligned correctly. Is there any update function which I have to call after loading a layout file?
And second: As you can see I create one StaticImage in another widget so that the scaling isn't affected by the 4:3 screen resolution. After resizing the window the parent widget is centered, but the crosshair image is NOT centered within its parent widget. How can I do this?
I'm using MyGUI SVN 2162.
My code:
MyGUI::OgrePlatform *mPlatform = new MyGUI::OgrePlatform();
mPlatform->initialise(mWindow); // mWindow is Ogre::RenderWindow* where you want to render MyGUI
mGUI = new MyGUI::Gui();
mGUI->initialise();
// load layout
MyGUI::LayoutManager::getInstance().load("SMR.layout");
My layout file:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Widget" skin="Default" position="0 0 100 100" align="Center" layer="Back">
<Widget type="StaticImage" skin="StaticImage" position_real="0 0 0.28 0.28" align="Center" layer="Back" name="crosshair">
<Property key="Image_Texture" value="crosshair.png"/>
</Widget>
</Widget>
<Widget type="StaticImage" skin="StaticImage" position_real="0 0 0.3 0.3" align="Center" layer="Back" name="crosshair2">
<Property key="Image_Texture" value="crosshair.png"/>
</Widget>
</MyGUI>
The problem is the widgets don't get centered. Only when I resize the Ogre window they get aligned correctly. Is there any update function which I have to call after loading a layout file?
And second: As you can see I create one StaticImage in another widget so that the scaling isn't affected by the 4:3 screen resolution. After resizing the window the parent widget is centered, but the crosshair image is NOT centered within its parent widget. How can I do this?
I'm using MyGUI SVN 2162.