JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx

上传人:b****1 文档编号:13748562 上传时间:2022-10-13 格式:DOCX 页数:27 大小:104.99KB
下载 相关 举报
JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx_第1页
第1页 / 共27页
JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx_第2页
第2页 / 共27页
JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx_第3页
第3页 / 共27页
JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx_第4页
第4页 / 共27页
JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx_第5页
第5页 / 共27页
点击查看更多>>
下载资源
资源描述

JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx

《JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx》由会员分享,可在线阅读,更多相关《JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx(27页珍藏版)》请在冰豆网上搜索。

JME手机游戏设计方案案例源代码SpaceWarWord文件下载.docx

publicGameMID(){

display=Display.getDisplay(this)。

//获取Display

gm=newGameMusic()。

loadFlashScreen()。

//加载闪屏画面

}

publicvoidstartApp(){

publicvoidpauseApp(){

publicvoiddestroyApp(booleanunconditional){

gmenu=null。

flashscreen=null。

startscreen=null。

gm=null。

GameMusic.releases()。

System.gc()。

//释放资源

/*退出程序*/

publicvoidexit(){

try{

destroyApp(false)。

}catch(Exceptione){}

notifyDestroyed()。

/*加载游戏启动画面*/

publicvoidloadStartScreen(){

startscreen=newStartScreen(this)。

//创建启动画面

display.setCurrent(startscreen)。

//设置启动画面为当前显示画面

/*加载闪屏画面*/

publicvoidloadFlashScreen(){

flashscreen=newFlashScreen(this)。

//创建闪屏

display.setCurrent(flashscreen)。

//设置闪屏画面为当前显示画面

/*加载游戏菜单*/

publicvoidloadGameMenu(intmenuIndex){

if(gmenu==null){

gmenu=newGameMenu(this)。

//创建菜单

gmenu.setMenuIndex(menuIndex)。

//设置当前菜单项

display.setCurrent(gmenu)。

//设置菜单画面为当前显示画面

/*加载游戏主界面*/

publicvoidloadGameWorld(){

if(gw==null){

gw=newGameWorld(this)。

//创建游戏引擎画布

display.setCurrent(gw)。

//设置游戏引擎画布为当前显示画面

gw.start()。

}

********FlashScreen

importjava.io.IOException。

importjava.util.Timer。

importjava.util.TimerTask。

importjavax.microedition.lcdui.Canvas。

importjavax.microedition.lcdui.Graphics。

importjavax.microedition.lcdui.Image。

/*

*Tochangethistemplate,chooseTools|Templates

*andopenthetemplateintheeditor.

*/

/**

*

*@authorWizardyx

/*闪屏画面*/

publicclassFlashScreenextendsCanvas{

GameMIDmid。

Imageimg。

privateTimertimer。

//声明定时器

privateTimerTasktask。

//声明定时器任务

/*构造方法*/

publicFlashScreen(GameMIDmid){

this.mid=mid。

try{

img=Image.createImage("

/logo.png"

)。

}catch(IOExceptionex){

ex.printStackTrace()。

FlashTimer()。

//闪屏计时

repaint()。

//绘制闪屏画面

publicvoidrelease(){

img=null。

/*按键事件处理,按任意键均加载游戏菜单画面*/

protectedvoidkeyPressed(intkeyCode){

super.keyPressed(keyCode)。

timer.cancel()。

release()。

mid.loadGameMenu

(1)。

//加载游戏菜单

/*绘制闪屏画面*/

protectedvoidpaint(Graphicsg){

g.drawImage(img,0,0,Graphics.TOP|Graphics.LEFT)。

/*闪屏画面计时*/

privatevoidFlashTimer(){

timer=newTimer()。

//创建定时器

task=newTimerTask(){//创建定时任务

privateinttimes=0。

//计时变量

publicvoidrun(){

times++。

//task任务计时,每次增加100ms(下面任务启动中定义)

if(times>

10){//3000ms后,自动加载游戏启动界面

mid.loadStartScreen()。

//加载游戏启动界面

}。

//启动task任务,在0ms后开始,每隔300ms运行一次

timer.schedule(task,0,300)。

*******GameMenu

importjavax.microedition.lcdui.game.GameCanvas。

importjavax.microedition.lcdui.game.Sprite。

*@authorAdministrator

publicclassGameMenuextendsGameCanvas{

privateGameMIDmid。

//声明MIDlet

privateintMenuIndex。

//菜单项索引

privatefinalbyteglt=Graphics.LEFT|Graphics.TOP。

//锚点

privateImagebackground,menu,menuarrow,icon。

//菜单图像

privateintmenuY=270。

//菜单Y坐标

privateintmenuArrowX=65。

//箭头X坐标

//定时器任务

publicGameMenu(GameMIDmid){

super(false)。

this.setFullScreenMode(true)。

//设置为全屏模式

//设置MIDlet

MenuIndex=1。

//初始化菜单项索引

InitImage()。

//初始化图像

menuAnima()。

//菜单动画

GameMusic.playStoryMusic()。

//播放背景音乐

/*初始化图像*/

privatevoidInitImage(){

//加载图像资源

background=Image.createImage("

/background.png"

menu=Image.createImage("

/menu.png"

menuarrow=Image.createImage("

/menuarrow.png"

icon=Image.createImage("

/menuIcon.png"

publicvoidrender(){

Graphicsg=this.getGraphics()。

g.drawImage(background,0,0,glt)。

//绘制背景

g.drawImage(icon,40,60,glt)。

//绘制菜单项

g.drawRegion(menu,0,MenuIndex*18,72,18,Sprite.TRANS_NONE,83,menuY,glt)。

//绘制箭头

g.drawImage(menuarrow,menuArrowX,menuY,glt)。

g.drawRegion(menuarrow,0,0,16,18,Sprite.TRANS_MIRROR,224-menuArrowX,menuY,glt)。

flushGraphics()。

//更新绘图

/*获取当前菜单项索引*/

publicintgetMenuIndex(){

returnMenuIndex。

/*设置当前菜单项索引*/

publicvoidsetMenuIndex(intMenuIndex){

t

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 少儿英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1