mt2503 11A之后,如何添加native 2D game
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
从11A开始,mtk对game这块进行调整,之前的2Dgame都phaseout了,mtk将不会对这块support了,但是具体的实现code依然保留。
[SOLUTION]
如果要在11A之后的平台上添加2dgame,如puzzle、snake、UFO之类的,需要自行补上以下code:
以GAME_UFO为例:
1.首先game的compileoption都应该在MMI_features.h里面配置:
/plutommi/MMI/Inc/MMI_features.h
2.相关的compileoption
#ifdefined(CFG_MMI_GAME_MENU)&&((CFG_MMI_GAME_MENU==__ON__)||(CFG_MMI_GAME_MENU==__AUTO
__))&&\
(!defined(GE_BROGENT)&&!defined(GE_INTERGRAFX))
#ifndef__MMI_GAME_MENU__
#define__MMI_GAME_MENU__
#endif
#endif
定义UFOgame的compileoption
#ifdefined(CFG_MMI_GAME_UFO)&&((CFG_MMI_GAME_UFO==__ON__)||(CFG_MMI_GAME_UFO==__AUTO__)
)&&\
(defined(__MMI_GAME_MENU__)&&(defined(__MMI_MAINLCD_128X128__)||defined(__MMI_MAINLCD_1
28X160__)||defined(__MMI_MAINLCD_176X220__)))
#ifndef__MMI_GAME_UFO__
#define__MMI_GAME_UFO__
#endif
#endif
如果有游戏,就定义出__MMI_GAME__
#if(defined(__MMI_GAME_CHICKEN__)||defined(__MMI_GAME_COLORBALLS__)||defined(__MMI_GAME
_COPTER__)||defined(__MMI_GAME_DANCE__)||defined(__MMI_GAME_DOLL__)||defined(__MMI_GAME
_F1RACE__)||defined(__MMI_GAME_FRUIT__)||defined(__MMI_GAME_HANOI__)||defined(__MMI_GAM
E_JET__)||defined(__MMI_GAME_MAGICSUSHI__)||defined(__MMI_GAME_MAJUNG__)||defined(__MMI
_GAME_memory__)||defined(__MMI_GAME_MONKEY__)||defined(__MMI_GAME_NINJA__)||defined(__M
MI_GAME_PANDA__)||defined(__MMI_GAME_PUZZLE__)||defined(__MMI_GAME_RICHES__)||defined(_
_MMI_GAME_ROBOT__)||defined(__MMI_GAME_SMASH__)||defined(__MMI_GAME_SNAKE__)||defined(_
_MMI_GAME_SUBMARINE__)||defined(__MMI_GAME_UFO__)||defined(__MMI_GAME_VSMJ__))
#ifndef__MMI_GAME__
#define__MMI_GAME__
#endif
#endif
定义UFOgame在128*160分辨率的手机上的compileoption
#if(defined(__MMI_GAME_UFO__)&&defined(__MMI_MAINLCD_128X160__))
#ifndef__MMI_GAME_UFO_128x160__
#define__MMI_GAME_UFO_128x160__
#endif
#endif
3.UFOgame是怎么加到游戏菜单里面的
1)Gamephp?mod=tag&id=6090" target="_blank" class="relatedlink">Framework有两个文件
/plutommi/MMI/FunAndGames/FunAndGamesSrc/Game.c
Game.c是将各个游戏加到菜单里的
/plutommi/MMI/FunAndGames/FunAndGamesSrc/GameFramework.c
GameFramework.c是生成每个游戏里面的开始,分数,帮助菜单的
这两个文件都是被__MMI_GAME__包起来的
2)这是将UFOgame加到菜单的code
#ifdefIS_UFO_BASE_GAME
/*ufo*/
#ifdefined(__MMI_GAME_UFO_128x160__)||defined
(__MMI_GAME_UFO_128x128__)||defined(__MMI_GAME_UFO_176x220__)
menu_str[index]=STR_ID_GX_UFO_GAME_NAME;
menu_img[index++]=IMG_ID_GX_UFO_GAME_ICON;
/*airforce*/
#elifdefined(__MMI_GAME_AIRFORCE_128x160__)||defined(__MMI_GAME_AIRFORCE_128x128__)
menu_str[index]=STR_ID_GX_UFO_GAME_NAME_AIRFORCE;
menu_img[index++]=IMG_ID_GX_UFO_GAME_ICON;
#endif
#endif/*IS_UFO_BASE_GAME*/
可以看到添加game的时候依赖的compileoption是IS_XXXX_BASE_GAME
3)定义上面的compileoption在这个文件:GameResDef.h
/plutommi/MMI/FunAndGames/FunAndGamesSrc/GameResDef.h
可以看到IS_XXXX_BASE_GAME依赖于__MMI_GAME_XXXXX_widthxheight__
#ifdefined(__MMI_GAME_UFO_128x128__)||defined(__MMI_GAME_UFO_128x160__)||defined(__MMI_
GAME_UFO_176x220__)
#defineIS_UFO_BASE_GAME
#endif
4)在ufo.c里面,整个.c文件是被IS_UFO_BASE_GAME包起来的
而不同分辨率的画面坐标是根据__MMI_GAME_UFO_widthxheight__来定的
4.UFOgame打开方法
整个compileoption的依赖关系大概就是这样的
IS_UFO_BASE_GAME__MMI_GAME_UFO_128x160____MMI_GAME_UFO____MMI_GAME_MENU__
__MMI_GAME____MMI_GAME_UFO__
根据上面compileoption的介绍,想在11A以后的branch上打开一个游戏,可以找个一个简单的,不是很规范的方法:
1)在mmi_feature.h里面直接定义出__MMI_GAME__,这个是必须的,有了这个才会有“game”这个菜单项出现在“funandgame”这个menu里面,gameframework才能work
2)直接定义出__MMI_GAME_UFO_128x160__
这个方法比较适合处理issue时候,手头没有开这个游戏的load,可以通过这个方法打开某个游戏需要resourcegen,然后remakemmiresourcemmi_frameworkmedia_app
规范的做法就是到mmi_features.h里面从头到尾把这些compileoption都给定义出来,然后到mmi_features_switchPLUTO.h里面配置CFG
5.如果是11A及以后的branch,记得去mcu\make\plutommi\media_app\media_app.mak下把这些游戏的.c加到SCR_LIST里面去,如下:
ifneq($(fiLTEr__MMI_GAME_UFO__,$(strip$(MODULE_DEFS))),)
SRC_LIST+=plutommi\mmi\funandgames\funandgamessrc\ufo.c
endif
从11A开始,mtk对game这块进行调整,之前的2Dgame都phaseout了,mtk将不会对这块support了,但是具体的实现code依然保留。
[SOLUTION]
如果要在11A之后的平台上添加2dgame,如puzzle、snake、UFO之类的,需要自行补上以下code:
以GAME_UFO为例:
1.首先game的compileoption都应该在MMI_features.h里面配置:
/plutommi/MMI/Inc/MMI_features.h
2.相关的compileoption
#ifdefined(CFG_MMI_GAME_MENU)&&((CFG_MMI_GAME_MENU==__ON__)||(CFG_MMI_GAME_MENU==__AUTO
__))&&\
(!defined(GE_BROGENT)&&!defined(GE_INTERGRAFX))
#ifndef__MMI_GAME_MENU__
#define__MMI_GAME_MENU__
#endif
#endif
定义UFOgame的compileoption
#ifdefined(CFG_MMI_GAME_UFO)&&((CFG_MMI_GAME_UFO==__ON__)||(CFG_MMI_GAME_UFO==__AUTO__)
)&&\
(defined(__MMI_GAME_MENU__)&&(defined(__MMI_MAINLCD_128X128__)||defined(__MMI_MAINLCD_1
28X160__)||defined(__MMI_MAINLCD_176X220__)))
#ifndef__MMI_GAME_UFO__
#define__MMI_GAME_UFO__
#endif
#endif
如果有游戏,就定义出__MMI_GAME__
#if(defined(__MMI_GAME_CHICKEN__)||defined(__MMI_GAME_COLORBALLS__)||defined(__MMI_GAME
_COPTER__)||defined(__MMI_GAME_DANCE__)||defined(__MMI_GAME_DOLL__)||defined(__MMI_GAME
_F1RACE__)||defined(__MMI_GAME_FRUIT__)||defined(__MMI_GAME_HANOI__)||defined(__MMI_GAM
E_JET__)||defined(__MMI_GAME_MAGICSUSHI__)||defined(__MMI_GAME_MAJUNG__)||defined(__MMI
_GAME_memory__)||defined(__MMI_GAME_MONKEY__)||defined(__MMI_GAME_NINJA__)||defined(__M
MI_GAME_PANDA__)||defined(__MMI_GAME_PUZZLE__)||defined(__MMI_GAME_RICHES__)||defined(_
_MMI_GAME_ROBOT__)||defined(__MMI_GAME_SMASH__)||defined(__MMI_GAME_SNAKE__)||defined(_
_MMI_GAME_SUBMARINE__)||defined(__MMI_GAME_UFO__)||defined(__MMI_GAME_VSMJ__))
#ifndef__MMI_GAME__
#define__MMI_GAME__
#endif
#endif
定义UFOgame在128*160分辨率的手机上的compileoption
#if(defined(__MMI_GAME_UFO__)&&defined(__MMI_MAINLCD_128X160__))
#ifndef__MMI_GAME_UFO_128x160__
#define__MMI_GAME_UFO_128x160__
#endif
#endif
3.UFOgame是怎么加到游戏菜单里面的
1)Gamephp?mod=tag&id=6090" target="_blank" class="relatedlink">Framework有两个文件
/plutommi/MMI/FunAndGames/FunAndGamesSrc/Game.c
Game.c是将各个游戏加到菜单里的
/plutommi/MMI/FunAndGames/FunAndGamesSrc/GameFramework.c
GameFramework.c是生成每个游戏里面的开始,分数,帮助菜单的
这两个文件都是被__MMI_GAME__包起来的
2)这是将UFOgame加到菜单的code
#ifdefIS_UFO_BASE_GAME
/*ufo*/
#ifdefined(__MMI_GAME_UFO_128x160__)||defined
(__MMI_GAME_UFO_128x128__)||defined(__MMI_GAME_UFO_176x220__)
menu_str[index]=STR_ID_GX_UFO_GAME_NAME;
menu_img[index++]=IMG_ID_GX_UFO_GAME_ICON;
/*airforce*/
#elifdefined(__MMI_GAME_AIRFORCE_128x160__)||defined(__MMI_GAME_AIRFORCE_128x128__)
menu_str[index]=STR_ID_GX_UFO_GAME_NAME_AIRFORCE;
menu_img[index++]=IMG_ID_GX_UFO_GAME_ICON;
#endif
#endif/*IS_UFO_BASE_GAME*/
可以看到添加game的时候依赖的compileoption是IS_XXXX_BASE_GAME
3)定义上面的compileoption在这个文件:GameResDef.h
/plutommi/MMI/FunAndGames/FunAndGamesSrc/GameResDef.h
可以看到IS_XXXX_BASE_GAME依赖于__MMI_GAME_XXXXX_widthxheight__
#ifdefined(__MMI_GAME_UFO_128x128__)||defined(__MMI_GAME_UFO_128x160__)||defined(__MMI_
GAME_UFO_176x220__)
#defineIS_UFO_BASE_GAME
#endif
4)在ufo.c里面,整个.c文件是被IS_UFO_BASE_GAME包起来的
而不同分辨率的画面坐标是根据__MMI_GAME_UFO_widthxheight__来定的
4.UFOgame打开方法
整个compileoption的依赖关系大概就是这样的
IS_UFO_BASE_GAME__MMI_GAME_UFO_128x160____MMI_GAME_UFO____MMI_GAME_MENU__
__MMI_GAME____MMI_GAME_UFO__
根据上面compileoption的介绍,想在11A以后的branch上打开一个游戏,可以找个一个简单的,不是很规范的方法:
1)在mmi_feature.h里面直接定义出__MMI_GAME__,这个是必须的,有了这个才会有“game”这个菜单项出现在“funandgame”这个menu里面,gameframework才能work
2)直接定义出__MMI_GAME_UFO_128x160__
这个方法比较适合处理issue时候,手头没有开这个游戏的load,可以通过这个方法打开某个游戏需要resourcegen,然后remakemmiresourcemmi_frameworkmedia_app
规范的做法就是到mmi_features.h里面从头到尾把这些compileoption都给定义出来,然后到mmi_features_switchPLUTO.h里面配置CFG
5.如果是11A及以后的branch,记得去mcu\make\plutommi\media_app\media_app.mak下把这些游戏的.c加到SCR_LIST里面去,如下:
ifneq($(fiLTEr__MMI_GAME_UFO__,$(strip$(MODULE_DEFS))),)
SRC_LIST+=plutommi\mmi\funandgames\funandgamessrc\ufo.c
endif