Mercurial > MadButterfly
annotate examples/dynamic/hello.c @ 399:31b6633e3538
- Fix a minor error in src/sprite.c: should check *(s-1) instead of
*s or the pointer will stop at '/', which is not what we want.
- Fix various load path errors in examples because libtool put .so
into .libs directory.
- Fix an error in examples/dynamic/Makefile.am: scene_la_SOURCES
should be scene.c instead of mytext.c
author | john.cylee@gmail.com |
---|---|
date | Fri, 12 Jun 2009 18:36:15 +0800 |
parents | 433fa83d16f9 |
children | 84ce2d4a8c3f |
rev | line source |
---|---|
247 | 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> | |
387
433fa83d16f9
Corrected build dependence - able to build in Ubuntu Intrepid
Ben Lau <xbenlau@gmail.com>
parents:
247
diff
changeset
|
10 //#include "menu.h" |
247 | 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 | |
399
31b6633e3538
- Fix a minor error in src/sprite.c: should check *(s-1) instead of
john.cylee@gmail.com
parents:
387
diff
changeset
|
51 myApp = MBApp_Init(".libs/scene"); |
247 | 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 */ |