diff --git a/examples/push_box/PlayScene.cpp b/examples/push_box/PlayScene.cpp index 098999d..fe84c96 100644 --- a/examples/push_box/PlayScene.cpp +++ b/examples/push_box/PlayScene.cpp @@ -118,20 +118,20 @@ void PlayScene::onUpdate(float dt) { auto& input = app.input(); // B 键返回主菜单 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_B)) { + if (input.isButtonPressed(extra2d::GamepadButton::B)) { app.scenes().replaceScene( extra2d::makePtr(), extra2d::TransitionType::Fade, 0.2f); return; } // Y 键重开 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_Y)) { + if (input.isButtonPressed(extra2d::GamepadButton::Y)) { setLevel(g_CurrentLevel); return; } // X键直接切换音效 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_X)) { + if (input.isButtonPressed(extra2d::GamepadButton::X)) { g_SoundOpen = !g_SoundOpen; AudioManager::instance().setEnabled(g_SoundOpen); updateSoundIcon(); @@ -139,22 +139,22 @@ void PlayScene::onUpdate(float dt) { } // A 键执行选中的菜单项 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_A)) { + if (input.isButtonPressed(extra2d::GamepadButton::A)) { executeMenuItem(); return; } // 方向键移动 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_DPAD_UP)) { + if (input.isButtonPressed(extra2d::GamepadButton::DPadUp)) { move(0, -1, 1); flush(); - } else if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_DPAD_DOWN)) { + } else if (input.isButtonPressed(extra2d::GamepadButton::DPadDown)) { move(0, 1, 2); flush(); - } else if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_DPAD_LEFT)) { + } else if (input.isButtonPressed(extra2d::GamepadButton::DPadLeft)) { move(-1, 0, 3); flush(); - } else if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) { + } else if (input.isButtonPressed(extra2d::GamepadButton::DPadRight)) { move(1, 0, 4); flush(); } else { diff --git a/examples/push_box/SuccessScene.cpp b/examples/push_box/SuccessScene.cpp index be2c1ab..2cb2cb3 100644 --- a/examples/push_box/SuccessScene.cpp +++ b/examples/push_box/SuccessScene.cpp @@ -67,7 +67,7 @@ void SuccessScene::onUpdate(float dt) { auto& input = app.input(); // A键确认返回主菜单 - if (input.isButtonPressed(SDL_CONTROLLER_BUTTON_A)) { + if (input.isButtonPressed(extra2d::GamepadButton::A)) { auto& scenes = extra2d::Application::instance().scenes(); scenes.popScene(extra2d::TransitionType::Fade, 0.2f); scenes.popScene(extra2d::TransitionType::Fade, 0.2f);