Я работаю над фейерверком для своего времени в Пеббл, и решил, что хочу, чтобы у него было изображение в фоновом режиме. Eveything работает, за исключением одной строки кода.Pebble Cloud не узнает мой ресурс
meri_image = gbitmap_create_with_resource(pika);
Когда я иду, чтобы построить свою программу, он дает мне ошибку
../src/window.c:53:45: error: 'pika' undeclared (first use in this function)
Идентификатор изображения пищуха. Я не вижу, что я делаю неправильно.
Здесь представлен весь код для приложения.
#include <pebble.h>
static Window *s_window;
static TextLayer *s_text_layer;
static BitmapLayer *meri_image_layer;
static GBitmap *meri_image;
void handle_timechanges(struct tm *tick_time, TimeUnits units_changed) {
static char time_buffer[10];
strftime(time_buffer, sizeof(time_buffer), "%H:%M", tick_time);
text_layer_set_background_color(s_text_layer, GColorCobaltBlue);
text_layer_set_text_color(s_text_layer, GColorCyan);
text_layer_set_text(s_text_layer, time_buffer);
text_layer_set_text_alignment(s_text_layer,GTextAlignmentCenter);
text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
}
static void init(void) {
// Create a window and get information about the window
s_window = window_create();
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_bounds(window_layer);
// Create a text layer and set the text
s_text_layer = text_layer_create(bounds);
text_layer_set_text(s_text_layer, "Time is loading....");
// Set the font and text alignment
text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
// Add the text layer to the window
layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_text_layer));
tick_timer_service_subscribe(SECOND_UNIT, handle_timechanges);
// Enable text flow and paging on the text layer, with a slight inset of 10, for round screens
text_layer_enable_screen_text_flow_and_paging(s_text_layer, 10);
meri_image_layer = bitmap_layer_create(bounds);
meri_image = gbitmap_create_with_resource(pika);
// Push the window, setting the window animation to 'true'
window_stack_push(s_window, true);
// App Logging!
APP_LOG(APP_LOG_LEVEL_DEBUG, "The Watcface has loaeded!");
}
static void deinit(void) {
gbitmap_destroy(meri_image);
bitmap_layer_destroy(meri_image_layer);
// Destroy the text layer
text_layer_destroy(s_text_layer);
// Destroy the window
window_destroy(s_window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
Я думаю, что это связано с проблемой с Pebble Cloud, но я хотел бы услышать ваш совет. Спасибо за помощь.
Сообщение не может быть яснее! Покажите объявление 'pika'. См. [Ask] и укажите [mcve]. – Olaf
То, что строка кода предназначена для объявления изображения. – Andrew
Возможно, вам следует изучить основы C и многих других языков программирования? Я не знаю и забочусь о том, какой тип 'pika', но вы его не объявляете (узнайте, что это значит!) – Olaf