由于窗口大小,无法将全屏位图添加到Pebble

时间:2015-04-26 02:18:50

标签: c pebble-watch pebble-sdk

我正在使用Pebble SDK 2并遇到图形问题。

我试图添加尺寸为144 x 168的全屏图形,但是,当我这样做时 - 底部会被剪裁。

[picture]

进一步调查 - 根层的尺寸为144 x 152而不是144 x 168(Pebble的全屏尺寸)。我在添加位图并调用window_stack_push之前将窗口设置为全屏,因此状态栏应该不是问题(尽管状态栏的尺寸应该适合我缺少的空间)。

代码如下:

void handle_init(void) {
  s_main_window = window_create();
  window_set_fullscreen(s_main_window, true);

  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
  const bool animated = true;
  window_set_click_config_provider(s_main_window, click_config_provider);
  window_stack_push(s_main_window, animated);
}

static void main_window_load(Window *window) {
  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CHILL_BG5);
  s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
}

更新代码:

static void breathe_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap_3 = gbitmap_create_with_resource(RESOURCE_ID_CHILL_BG6);
  s_background_layer_3 = bitmap_layer_create(GRect(0, -16, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer_3, s_background_bitmap_3);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer_3));
}

static void breathe_window_unload(Window *window) {
  gbitmap_destroy(s_background_bitmap_3);
  bitmap_layer_destroy(s_background_layer_3);
  animation_unschedule_all();
  window_destroy(s_window_2);
}

static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
  s_window_2 = window_create();
  window_set_window_handlers(s_window_2, (WindowHandlers) {
    .load = breathe_window_load,
    .unload = breathe_window_unload
  });  
  const bool animated = true;
  window_stack_push(s_window_2, animated);

  next_animation();
}

0 个答案:

没有答案