本文整理汇总了C++中InputState::isDown方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::isDown方法的具体用法?C++ InputState::isDown怎么用?C++ InputState::isDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::isDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUpdate
void MenuView::OnUpdate(const float dt) {
InputState inputState;
mCommon->getInputState(&inputState);
accumulatorKeyPress -= dt;
if (accumulatorKeyPress <= 0) {
accumulatorKeyPress = 0;
}
if (inputState.isDown(Button::BUTTON_MOUSELEFT) && accumulatorKeyPress == 0) {
mModel->CheckInput(Vec2(inputState.mMouseX, inputState.mMouseY));
accumulatorKeyPress = delayKeyPress;
}
}
示例2: gameLoop
void gameLoop() {
wParams.mFullscreen = false;
wParams.mHeight = screenHeight;
wParams.mWidth = screenWidth;
wParams.mTitle = "Laboration 2";
wParams.mPosX = 0;
wParams.mPosY = 0;
if (common.init(wParams)) {
common.registerTextureResource("explosion", "image/explosion.png");
EventManager em;
common.setEventProcessor(&em);
Graphics *g = common.getGraphics();
g->setViewport(0, 0, screenWidth, screenHeight);
Renderer2D *renderer = g->createRenderer2D();
float rot = 0.0f;
HiResTimer timer;
timer.restart();
//Set program scale.
AnimationSystem animationSystem(common);
const float TIME_STEP = 1.0 / 50.0f;
float accumulator = 0.0f;
while (gRunning) {
common.getInputState(&inputState);
if (inputState.isDown(Button::BUTTON_ESCAPE)) {
gRunning = 0;
}
common.frame();
timer.tick();
g->clear(Color::Black, true);
accumulator += timer.getDeltaSeconds();
while (accumulator >= TIME_STEP) {
accumulator -= TIME_STEP;
animationSystem.UpdateEmitter(TIME_STEP);
}
renderer->begin(Renderer2D::SPRITE_SORT_DEFERRED, Renderer2D::SPRITE_BLEND_ALPHA);
animationSystem.RenderEmitter(renderer);
rot += timer.getDeltaSeconds() * 0.1f;
renderer->end();
g->present();
}
animationSystem.FreeMem();
}
}
示例3: gameLoop
void GameController::gameLoop() {
wParams.mFullscreen = false;
wParams.mHeight = screenHeight;
wParams.mWidth = screenWidth;
wParams.mTitle = "Project";
wParams.mPosX = 0;
wParams.mPosY = 0;
if (common.init(wParams)) {
//Load all textures
common.registerSoundResource("soundExplosion", "sound/explosion.ogg");
common.registerSoundResource("soundShoot", "sound/fire.ogg");
common.registerTextureResource("shoot", "image/spark.png");
common.registerTextureResource("plane", "image/plane.png");
common.registerTextureResource("explosion", "image/explosion.png");
common.registerTextureResource("asteroid1", "image/asteroid1.png");
common.registerTextureResource("asteroid2", "image/asteroid2.png");
common.registerTextureResource("asteroid3", "image/asteroid3.png");
common.registerTextureResource("asteroid4", "image/asteroid4.png");
common.registerTextureResource("asteroid5", "image/asteroid5.png");
common.registerTextureResource("asteroid6", "image/asteroid6.png");
common.registerTextureResource("background_menu", "image/space_background_menu.png");
common.registerTextureResource("background_after_game", "image/space_background_after_game.png");
common.registerTextureResource("health_package", "image/health_package.png");
common.registerFontResource("sans16", 16, "fonts/ARIAL.ttf");
common.registerFontResource("sans20", 20, "fonts/OpenSans-Regular.ttf");
common.registerFontResource("lobsterBold", 30, "fonts/LobsterTWo-Bold.otf");
EventManager em;
common.setEventProcessor(&em);
Graphics *g = common.getGraphics();
g->setViewport(0, 0, screenWidth, screenHeight);
HiResTimer timer;
timer.restart();
SetAsteroidType(currentLvl);
Model::MenuModel menuModel;
View::MenuView menuView(&common, &menuModel);
menuModel.AddView(&menuView);
int height, width;
common.getGraphics()->getContextSize(&width, &height);
menuModel.Init(Vec2(width, height));
Model::ManagerModel *managerModel = DBG_NEW Model::ManagerModel;
View::ManagerView *managerView = DBG_NEW View::ManagerView(&common, managerModel);
managerModel->AddView(managerView);
common.getGraphics()->getContextSize(&width, &height);
managerModel->Init(Vec2(width, height), GetAsteroidType().typ1, GetAsteroidType().type2, maxScore, currentLvl);
currentState = GAMESTATE_INMENU;
while (gRunning) {
timer.tick();
// Process OS events.
common.frame();
if (timerEsc <= 0) {
timerEsc = 0;
} else {
timerEsc -= timer.getDeltaSeconds();
}
InputState input;
common.getInputState(&input);
if (input.isDown(Button::BUTTON_ESCAPE)) {
if (timerEsc <= 0) {
if (currentState == GAMESTATE_INGAME) {
currentState = GAMESTATE_INMENU;
} else {
currentState = GAMESTATE_INGAME;
}
timerEsc = coolDownEsc;
}
}
if (managerModel->WonRound() || managerModel->LostRound()) {
if (timerResultScreen <= 0) {
timerResultScreen = 0;
} else {
timerResultScreen -= timer.getDeltaSeconds();
}
if (managerModel->LostRound()) {
menuModel.ShowLostRound();
currentState = GAMESTATE_AFTER_GAME;
timerDelayScreenForExplosion = timeElapsedForExplosion;
} else {
if (currentLvl >= 2) {
//.........这里部分代码省略.........