Mercurial > MadButterfly
comparison examples/dynamic/text.c @ 291:137a73822d48
Add sh_text_set_style support to change the style of text element.
author | wycc |
---|---|
date | Sun, 01 Feb 2009 01:45:53 +0800 |
parents | 13ce87b6dbf5 |
children | 433fa83d16f9 |
comparison
equal
deleted
inserted
replaced
290:f65c4589549f | 291:137a73822d48 |
---|---|
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) | 25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) |
26 { | 26 { |
27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); | 27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); |
28 mb_timeval_t timer,interval; | 28 mb_timeval_t timer,interval; |
29 shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext"); | 29 shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext"); |
30 mb_textstyle_t style; | |
31 | |
32 mb_textstyle_init(&style); | |
30 | 33 |
31 | 34 |
32 get_now(&timer); | 35 get_now(&timer); |
33 MB_TIMEVAL_SET(&interval, 1 ,0); | 36 MB_TIMEVAL_SET(&interval, 1 ,0); |
34 MB_TIMEVAL_ADD(&timer, &interval); | 37 MB_TIMEVAL_ADD(&timer, &interval); |
36 | 39 |
37 en->currentscene = (en->currentscene + 1) % 2; | 40 en->currentscene = (en->currentscene + 1) % 2; |
38 printf("xxx\n"); | 41 printf("xxx\n"); |
39 if (en->currentscene == 0) { | 42 if (en->currentscene == 0) { |
40 sh_text_set_text(text,"This is 0"); | 43 sh_text_set_text(text,"This is 0"); |
44 mb_textstyle_set_color(&style, TEXTCOLOR_RGB(255,0,0)); | |
45 sh_text_set_style(text,0,5,&style); | |
41 } else { | 46 } else { |
42 sh_text_set_text(text,"This is 1"); | 47 sh_text_set_text(text,"This is 1"); |
48 mb_textstyle_set_color(&style, TEXTCOLOR_RGB(0,255,0)); | |
49 sh_text_set_style(text,0,5,&style); | |
43 } | 50 } |
44 rdman_shape_changed(MBAPP_RDMAN(myApp), text); | 51 rdman_shape_changed(MBAPP_RDMAN(myApp), text); |
45 #if 0 | 52 #if 0 |
46 /* Removed! | 53 /* Removed! |
47 * X_MB_handle_connection() will invoke it automatically. | 54 * X_MB_handle_connection() will invoke it automatically. |