本文整理汇总了C++中MEngine::getInputContext方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getInputContext方法的具体用法?C++ MEngine::getInputContext怎么用?C++ MEngine::getInputContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getInputContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void MInputManager::Update()
{
MEngine* engine = MEngine::getInstance();
if(MInputContext* input = engine->getInputContext())
{
for(commandVecIter iCommand = m_Commands.begin();
iCommand != m_Commands.end();
iCommand++)
{
commandDef::commandState state = (*iCommand)->state;
if(input->isKeyPressed((*iCommand)->command->GetKeyName()))
{
switch(state)
{
case commandDef::eUp:
case commandDef::eReleased:
(*iCommand)->command->OnKeyPressed();
(*iCommand)->state = commandDef::ePressed;
break;
case commandDef::ePressed:
case commandDef::eDown:
(*iCommand)->state = commandDef::eDown;
break;
}
}
else
{
switch(state)
{
case commandDef::eUp:
case commandDef::eReleased:
(*iCommand)->state = commandDef::eUp;
break;
case commandDef::ePressed:
case commandDef::eDown:
(*iCommand)->command->OnKeyReleased();
(*iCommand)->state = commandDef::eReleased;
break;
}
}
}
}
}
示例2: update
void MGame::update(void)
{
MEngine * engine = MEngine::getInstance();
// run script
if(engine->getScriptContext())
engine->getScriptContext()->callFunction("onSceneUpdate");
// get level
MLevel * level = MEngine::getInstance()->getLevel();
if(! level)
return;
// get current scene
MScene * scene = level->getCurrentScene();
if(! scene)
return;
// update behaviors
unsigned int i;
unsigned int oSize = scene->getObjectsNumber();
for(i=0; i<oSize; i++)
{
MObject3d * object = scene->getObjectByIndex(i);
if(! object->isActive())
continue;
object->updateBehaviors();
}
// update scene
scene->update();
// update physics
scene->updatePhysics();
// update objects matrices
scene->updateObjectsMatrices();
// flush input
engine->getInputContext()->flush();
}