diff options
Diffstat (limited to 'src/displayapp/screens/Paddle.cpp')
-rw-r--r-- | src/displayapp/screens/Paddle.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 79e0c3d3..26c2368b 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -27,13 +27,16 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_obj_set_size(ball, ballSize, ballSize); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Paddle::~Paddle() { + lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); } -bool Paddle::Refresh() { +void Paddle::Refresh() { ballX += dx; ballY += dy; @@ -44,8 +47,8 @@ bool Paddle::Refresh() { dy *= -1; } - // checks if it has touched the side (left side) - if (ballX >= LV_VER_RES - ballSize - 1) { + // checks if it has touched the side (right side) + if (ballX >= LV_HOR_RES - ballSize - 1) { dx *= -1; } @@ -65,7 +68,6 @@ bool Paddle::Refresh() { } } lv_label_set_text_fmt(points, "%04d", score); - return running; } bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { |