#include <BGE/All>
using namespace bge;
Window* createButton(const std::string& name,const String& text)
{
Button* button = new Button(,text);
button->setName(name);
button->setSize(Vector2f(,));
return button;
}
int main(int argc, char* argv[])
{
FileSystem::instance().initial(argv[]);
FileSystem::instance().setResourcePackage("data.zip");
WindowManager::instance().initialize("simkai.ttf",false);
Device* device = Device::create();
device->initial();
device->createWindow(,,bge::String("BGE Window"));
Panel* panel = new Panel(FloatRect(,,,),);
GridLayout* layout = new GridLayout();
panel->setLayout(layout);
std::vector<float> widths;
widths.push_back(0.0f);
layout->setColumnWidths(widths);
std::vector<float> heights;
for(int k = ; k < ; ++k)
heights.push_back(48.0f);
heights.push_back(0.0f);
layout->setRowHeights(heights);
GridCellInfo info;
info.columnIndex_ = ; info.rowIndex_ = ; layout->addWindow(createButton("button1",L"按键"),info);
info.columnIndex_ = ; info.rowIndex_ = ; layout->addWindow(createButton("button2",L"按键"),info);
info.columnIndex_ = ; info.rowIndex_ = ; layout->addWindow(createButton("button3",L"按键"),info);
info.columnIndex_ = ; info.rowIndex_ = ; layout->addWindow(createButton("button4",L"按键"),info);
info.columnIndex_ = ;
info.rowIndex_ = ;
info.horizontalSpan_ = ;
Window* edit = new EditField(NULL,L"Edit Text");
edit->setSize(Vector2f(,));
layout->addWindow(edit,info);
info.columnIndex_ = ;
info.rowIndex_ = ;
info.horizontalSpan_ = ;
layout->arrangeWithin();
FrameWindow* window = new FrameWindow();
window->enableMovement();
window->setText(L"BGE窗体");
window->setClientPanel(panel);
WindowManager::instance().addWindow(window);
while(device->isRunning())
{
device->preRender();
WindowManager::instance().update();
device->swapBuffers();
device->pollEvents();
}
WindowManager::instance().terminate();
device->closeWindow();
device->terminate();
device->deleteLater();
return ;
} 显示如下: 在开发上参考了Qt等软件,支持常见控件,控件序列化,整体换肤,控件换肤 以上代码写的相当啰嗦 其实可以这样写:int main(int argc, char* argv[])
{
FileSystem::instance().initial(argv[]);
FileSystem::instance().setResourcePackage("data.zip");
WindowManager::instance().initialize("simkai.ttf",false);
Device* device = Device::create();
device->initial();
device->createWindow(,,bge::String("BGE Window"));
Window* window = WindowManager::instance().createWindow("ui.xml");
if(window)
WindowManager::instance().addWindow(window);
while(device->isRunning())
{
device->preRender();
WindowManager::instance().update();
device->swapBuffers();
device->pollEvents();
}
WindowManager::instance().terminate();
device->closeWindow();
device->terminate();
device->deleteLater();
return ;
}做这个不为别的就是想做
现在有点小问题,修改好了我会上源码 欢饮指点~