本文整理汇总了C++中MEngine::getGame方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getGame方法的具体用法?C++ MEngine::getGame怎么用?C++ MEngine::getGame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getGame方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeCurrentScene
void MLevel::changeCurrentScene(unsigned int id)
{
if(id == m_currentSceneId)
return;
MEngine * engine = MEngine::getInstance();
if(id < getScenesNumber())
{
MScene * scene = getCurrentScene();
// onEndScene
MGame * game = engine->getGame();
if(game)
game->onEndScene();
// change scene
setCurrentSceneId(id);
scene = getCurrentScene();
// onBeginScene
if(game)
game->onBeginScene();
}
}
示例2: graphicLoop
void MaratisPlayer::graphicLoop(void)
{
MWindow * window = MWindow::getInstance();
MEngine * engine = MEngine::getInstance();
MRenderingContext * render = engine->getRenderingContext();
// game
MGame * game = engine->getGame();
if(game)
{
if(game->isRunning())
{
render->disableScissorTest();
render->setViewport(0, 0, window->getWidth(), window->getHeight());
game->draw();
}
else
{
render->clear(M_BUFFER_COLOR);
}
}
else
{
render->clear(M_BUFFER_COLOR);
}
}
示例3: logicLoop
void MaratisPlayer::logicLoop(void)
{
MEngine * engine = MEngine::getInstance();
// game
MGame * game = engine->getGame();
if(game)
{
if(game->isRunning()){
game->update();
}
}
}
示例4: update
void update(void)
{
MEngine * engine = MEngine::getInstance();
MGame * game = engine->getGame();
if(game)
{
if(game->isRunning())
{
game->update();
}
}
}
示例5: windowEvents
// window events
void windowEvents(MWinEvent * windowEvents)
{
MEngine * engine = MEngine::getInstance();
// game
MGame * game = engine->getGame();
if(game)
{
if(game->isRunning()){
gameWinEvents(windowEvents);
}
}
if(windowEvents->type == MWIN_EVENT_KEY_DOWN && windowEvents->data[0] == MKEY_ESCAPE){
MWindow::getInstance()->setActive(false);
}
if(windowEvents->type == MWIN_EVENT_WINDOW_CLOSE){
MWindow::getInstance()->setActive(false);
}
}
示例6: draw
void draw(void)
{
MWindow * window = MWindow::getInstance();
MEngine * engine = MEngine::getInstance();
MRenderingContext * render = engine->getRenderingContext();
MGame * game = engine->getGame();
// set basic viewport
render->disableScissorTest();
render->setViewport(0, 0, window->getWidth(), window->getHeight());
if(game)
{
if(game->isRunning())
{
game->draw();
}
}
window->swapBuffer();
}
示例7: main
//.........这里部分代码省略.........
render->createTexture(&logoTextureId);
render->bindTexture(logoTextureId);
render->sendTextureImage(&image, false, false, false);
// clear window
draw();
MGuiText text("LOADING", MVector2(480, 280), 16, MVector4(1, 1, 1, 1));
text.draw();
window->swapBuffer();
}
// load project
if(argc > 1)
{
maratis->loadProject(argv[1]);
}
// time
unsigned int frequency = 60;
unsigned long previousFrame = 0;
unsigned long startTick = window->getSystemTick();
int f = 0;
int t = 0;
// on events
while(window->isActive())
{
// on events
if(window->onEvents())
{
// compute target tick
unsigned long currentTick = window->getSystemTick();
unsigned long tick = currentTick - startTick;
unsigned long frame = (unsigned long)(tick * (frequency * 0.001f));
// update elapsed time
unsigned int i;
unsigned int steps = (unsigned int)(frame - previousFrame);
if(window->getFocus())
{
// don't wait too much
if(steps >= (frequency/2))
{
update();
draw();
previousFrame += steps;
continue;
}
// update
for(i=0; i<steps; i++)
{
update();
previousFrame++;
t++;
if(t == frequency)
{
MGame * game = engine->getGame();
if(game)
{
if(! game->isRunning())
MFilesUpdate::update();
}
else
{
MFilesUpdate::update();
}
//printf("fps:%d\n", f);
t = 0;
f = 0;
}
}
// draw
//if(steps > 0)
{
draw();
f++;
}
}
else
{
previousFrame = frame;
window->swapBuffer();
}
}
}
gui->clear();
maratis->clear();
return 0;
}