当前位置: 首页>>代码示例>>C++>>正文


C++ MEngine::getInputContext方法代码示例

本文整理汇总了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;
		}
	    }
	}
    }
}
开发者ID:galek,项目名称:MIngEd,代码行数:44,代码来源:MInputManager.cpp

示例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();
}
开发者ID:mconbere,项目名称:Newt,代码行数:42,代码来源:MGame.cpp


注:本文中的MEngine::getInputContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。