欢迎来到天天文库
浏览记录
ID:14385565
大小:58.00 KB
页数:31页
时间:2018-07-28
《j2me到android平台的游戏移植》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、J2ME到android平台的游戏移植将MIDP中的方法用android相关api来实现。publicclassMIDPDeviceimplementsDevice,NamedAndSpecialKeys,Runnable{privateintinitVolume;privateintcurrentVolume;privatebooleanmute;publicstaticfinalStringLOG_TAG="MIDPDevice";privateSurfaceUpdaterdragonView;//设置的屏幕宽高(即原始宽高),如果没有设置则读取屏幕真是宽高privatestat
2、icintoriginalWidth,originalHeight;//屏幕真实宽高privatestaticintscreenWidth,screenHeight;//按原始宽高生成双缓冲图privatestaticBitmapscreenBuffer;//双缓冲图的graphicspublicstaticGraphicsgraphics;publicintkey_interval=200;publicstaticfinalStringMEDIA_TEMP_FILE="temp";privateinttempCount=0;privatestaticfinalRecttempCli
3、p=newRect();privateintgcCount=0;privatestaticfinalHashMapKEY_NAME_AND_CODE=newHashMap(NAME_KEYS.length);privatebooleanhasRepeatEvents=false;privatebooleanfullScreenMode=true;privatebooleanhasPointerMotionEvents=true;privatebooleanrepaintDaemon=false;privateintdae
4、monCount=0;privatebooleanhasPointerEvents=false;publicMIDPDevice(){}publicStringgetName(){return"MIDPDevice";}publicvoidonCreate(Propertiesproperties){//音量initVolume=JavaApplicationManager.getInstance().getAndroidActivityProxy().getAudioManager().getStreamVolume(AudioManager.STREAM_MUSIC);curre
5、ntVolume=initVolume;dragonView=newDragonView(JavaApplicationManager.getInstance().getAndroidActivityProxy().getActivity());Log.i(getName(),"SurfaceUpdateriscreated.");//通过配置文件初始化变量initProperties(properties);initScreenBuffers(originalWidth,originalHeight);DragonView.virtualScreen=screenBuffer;if
6、(repaintDaemon){newThread(this).start();}System.gc();}privatevoidinitProperties(Propertiesproperties){try{//全屏if(properties.containsKey("screen.fullscreen")){fullScreenMode=Boolean.parseBoolean(properties.getProperty("screen.fullscreen"));}//屏幕真实宽高Displaydisplay=JavaApplicationManager.getInstan
7、ce().getAndroidActivityProxy().getActivity().getWindowManager().getDefaultDisplay();screenWidth=display.getWidth();screenHeight=display.getHeight();if(DeviceManager.device.getScreenWidth()==480){originalWidth=(int)(384);}elseif(De
此文档下载收益归作者所有