j2me手机游戏开发基础

j2me手机游戏开发基础

ID:37243083

大小:240.00 KB

页数:19页

时间:2019-05-12

j2me手机游戏开发基础_第1页
j2me手机游戏开发基础_第2页
j2me手机游戏开发基础_第3页
j2me手机游戏开发基础_第4页
j2me手机游戏开发基础_第5页
资源描述:

《j2me手机游戏开发基础》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、J2ME手机游戏开发基础目标安装/配置开发环境手机2D动画基础2手机游戏的实现技术嵌入式短信息J2ME3开发环境简介J2SE-1_5_0J2MEWirelessToolkit2.2Eclipse3.2.0Release版EclipseMe1.5(http://eclipseme.sourceforge.net)4MIDP的概念MobileInformationDeviceProfile移动信息设备简表具体实现MIDP简表的程序就称为MIDlet程序(简表就是针对具体的J2ME配置规范,如厂商NOKIA等)MIDP是由多家移动设备厂商一起设计提出是一个工业标准简表5搭建游戏框架

2、创建J2ME项目J2MEMidletSuite(Midlet程序套件)创建J2ME应用程序J2MEMidlet6HelloWorld!importjavax.microedition.lcdui.*;importjavax.microedition.midlet.*;publicclassHelloMIDletextendsMIDlet{privateTextBoxtextBox;publicHelloMIDlet(){textBox=newTextBox("HelloMIDlet","HelloWorld!",15,0);}protectedvoidstartApp()th

3、rowsMIDletStateChangeException{//显示textBox中的内容Display.getDisplay(this).setCurrent(textBox);}protectedvoidpauseApp(){}protectedvoiddestroyApp(booleanarg0)throwsMIDletStateChangeException{}}72D动画基础GameCanvas的基本概念及键盘控制方式提供了游戏的基本接口的抽象类(屏幕类)拥有屏幕缓冲可以直接得到键盘的物理状态,但很特殊8GameCanvas类基本开发流程获得图形接口绘制图形显示在

4、屏幕上Graphicsg;g=this.getGraphics();g.setColor(0,0,0);g.fillRect(,,,,);flushGraphics();示例:DrawBlackRect9快让我动起来吧GameCanvas类的键盘输入getKeyStates()函数可以直接获得键盘码但没有提供本身的键盘监听函数intkeyState=getKeyStates();if((keyState&UP_PRESSED)!=0){if(drawY-2>0){drawY=drawY-2;}else{drawY=getHeight();}}示例:MoveRect10Spri

5、te类简介用来实现人物动画、移动和碰撞检测Sprite类提供了分割图片的功能构造函数publicSprite(Imageimage)publicSprite(Spritesprite)publicSprite(Imagei,intframeWidth,intframeHeight)11创建Sprite对象privateSpritesprite;privateImagespriteImage;try{spriteImage=Image.createImage(“/npc01.png”);}catch(Exceptione){}sprite=newSprite(spriteIma

6、ge,32,48);12Sprite类开发01234567891011示例:MoveSpriteDemo13TiledLayer类构造函数publicTiledLayer(intcolumns,introws,Imageimage,inttiledWidth,inttiledHeight)用法TiledLayerbackground;tiledImage=Image.create(“/title.png”);background=newTiledLayer(3,3,tiledImage,tiledImage.getWidth()/3,tiledImage.getHeight(

7、)/3);14TiledLayer类开发123456789setCell(intcol,introw,inttiledIndex示例:TiledLayer,SpriteTiledDemo15LayerManagerLayerManagerlayManager;layManager=newLayerManager();layManager.append(background3);layManager.append(background2);layManager.append(background1);la

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。