change color upon game over

This commit is contained in:
Boteium 2023-07-04 18:11:19 +08:00
parent f12d5105c1
commit 2cd4b8bb5b
3 changed files with 6 additions and 5 deletions

View File

@ -530,7 +530,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
currentScreen = std::make_unique<Screens::Paddle>(lvgl);
break;
case Apps::Bird:
currentScreen = std::make_unique<Screens::Bird>(lvgl);
currentScreen = std::make_unique<Screens::Bird>();
break;
case Apps::Music:
currentScreen = std::make_unique<Screens::Music>(systemTask->nimble().music());

View File

@ -7,7 +7,7 @@
using namespace Pinetime::Applications::Screens;
Bird::Bird(Pinetime::Components::LittleVgl& lvgl) : lvgl {lvgl} {
Bird::Bird() {
lv_obj_t* background = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(background, LV_HOR_RES, LV_VER_RES);
@ -110,9 +110,10 @@ void Bird::Refresh() {
}
void Bird::GameOver() {
is_stopped = true;
lv_label_set_text_static(info, "Game Over");
lv_obj_align(info, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 40);
is_stopped = true;
lv_obj_set_style_local_text_color(bird, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
return;
}
@ -122,6 +123,7 @@ bool Bird::OnTouchEvent(Pinetime::Applications::TouchEvents /*event*/) {
pos = 120;
lv_label_set_text_static(info, "Touch to Start");
lv_obj_align(info, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 40);
lv_obj_set_style_local_text_color(bird, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
return true;
}
// reset

View File

@ -20,7 +20,7 @@ namespace Pinetime {
class Bird : public Screen {
public:
Bird(Pinetime::Components::LittleVgl& lvgl);
Bird();
~Bird() override;
void Refresh() override;
@ -31,7 +31,6 @@ namespace Pinetime {
private:
void GameOver();
void MovePipe();
Pinetime::Components::LittleVgl& lvgl;
bool is_stopped = true;
bool is_ascending = false;