comparison examples/dynamic/hello.c @ 247:d9a78c859660

Seperate the frameowrk codes from the main.c. Write a simpler MBAF demo hello program.
author wycc
date Thu, 01 Jan 2009 08:32:03 +0800
parents
children 433fa83d16f9
comparison
equal deleted inserted replaced
246:4df1b766bbf5 247:d9a78c859660
1 /*! \file
2 *
3 * svg2code_ex is an example that show programmers how to create a
4 * menu with MadButterfly.
5 *
6 */
7 #include <stdio.h>
8 #include <mb.h>
9 #include <string.h>
10 #include "menu.h"
11 #include "mbapp.h"
12
13
14 MBApp *myApp;
15
16 typedef struct {
17 shape_t *rect;
18 co_aix orx,ory;
19 int start_x,start_y;
20 observer_t *obs1,*obs2;
21 int currentscene;
22 }MyAppData;
23
24
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg)
26 {
27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
28 mb_timeval_t timer,interval;
29
30
31 get_now(&timer);
32 MB_TIMEVAL_SET(&interval, 1 ,0);
33 MB_TIMEVAL_ADD(&timer, &interval);
34 mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp);
35
36 en->currentscene = (en->currentscene + 1) % 2;
37 printf("switch to scene %d\n", en->currentscene + 1);
38 MB_SPRITE_GOTO_SCENE(myApp->rootsprite,en->currentscene + 1);
39 }
40
41 int main(int argc, char * const argv[]) {
42 subject_t *subject;
43 mb_button_t *b;
44 mb_obj_t *button;
45 MyAppData data;
46 mb_timeval_t tmo,interval;
47
48 if (argc > 1)
49 myApp = MBApp_Init(argv[1]);
50 else
51 myApp = MBApp_Init("scene");
52 data.currentscene=0;
53 MBApp_setData(myApp,&data);
54 //b = mb_button_new(myApp, myApp->rootsprite, "btn");
55 //mb_button_add_onClick(b, test,NULL);
56 get_now(&tmo);
57 MB_TIMEVAL_SET(&interval, 1 ,0);
58 mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp);
59
60
61 MBApp_loop(myApp);
62
63 return 0;
64 }
65
66 /* vim: set ts=4 */