📄 用midp实现贪吃蛇游戏(3).htm
字号:
COLOR: #194e00; LINE-HEIGHT: 20px
}
.center02 A:link {
COLOR: #194e00; TEXT-DECORATION: none
}
.center02 A:visited {
COLOR: #194e00; TEXT-DECORATION: none
}
.center02 A:hover {
COLOR: #194e00; TEXT-DECORATION: underline
}
</STYLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#f3f3f3
border=0 valign="top">
<TBODY>
<TR class=center01>
<TD style="PADDING-LEFT: 10px; PADDING-TOP: 10px" width=488><A
href="http://act.it.sohu.com/book/index.php">连载</A> > <A
href="http://act.it.sohu.com/book/slist.php?class1=6">程序设计</A> > <A
href="http://act.it.sohu.com/book/slist.php?class2=7">Java</A> > <A
href="http://act.it.sohu.com/book/serialize.php?id=461">Java手机游戏开发专辑</A>
</TD>
<TD style="PADDING-LEFT: 10px; PADDING-TOP: 10px" width=280>
<DIV align=center><FONT color=#0000ff><A
href="http://act.it.sohu.com/book/chapter.php?id=461&volume=4&chapter=13">上一页</A></FONT>
<FONT color=#0000ff><A
href="http://act.it.sohu.com/book/serialize.php?id=461">回书目</A></FONT>
<FONT
color=#0000ff>至末页</FONT>
</DIV></TD></TR>
<TR class=center01>
<TD style="PADDING-LEFT: 10px; PADDING-TOP: 10px" align=middle
colSpan=2> </TD></TR>
<TBODY>
<TR>
<TD align=middle colSpan=2><BR>
<DIV style="FONT-SIZE: 18pt; COLOR: #990000; FONT-FAMILY: 楷体_GB2312"
align=center><B>Java手机游戏开发实例</B></DIV><BR>
<DIV style="FONT-SIZE: 18px; COLOR: #990000; FONT-FAMILY: ; 宋体: "
align=center>用MIDP实现贪吃蛇游戏(3)</DIV>
<DIV
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE: 10.5pt; COLOR: black; LINE-HEIGHT: 180%"
align=left><BR>
<P><SPAN class=f14> <STRONG>WormMain类</STRONG>
<BR><BR> 最主要的类,继承自MIDlet父类并实现了CommandListener接口。<BR><BR> protected void
startApp()<BR><BR> 实现MIDlet父类的方法,当开始程序时首先执行这个函数<BR><BR></P>
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>
<P>//
显示画板<BR><BR>Display.getDisplay(this).setCurrent(theGame);<BR><BR>try
{<BR><BR>// 开始游戏线程<BR><BR>Thread myThread = new
Thread(theGame);<BR><BR>myThread.start();<BR><BR>} catch (Error e)
{<BR><BR>destroyApp(false);<BR><BR>notifyDestroyed();
}<BR><BR>public void commandAction(Command c, Displayable
d)<BR><BR> 接受并处理用户输入事件<BR><BR>// 重新开始<BR><BR>if (c == restartCmd)
{<BR><BR>theGame.restart();<BR><BR>}; <BR><BR>// 改变难度等级 <BR><BR>if
(c == levelCmd) {<BR><BR>Item[] levelItem = {<BR><BR>new
Gauge("Level", true, 9, theGame.getLevel())<BR><BR>};<BR><BR>Form f
= new Form("Change Level",
levelItem);<BR><BR>f.addCommand(OKCmd);<BR><BR>f.addCommand(cancelCmd);<BR><BR>f.setCommandListener(this);<BR><BR>Display.getDisplay(this).setCurrent(f);<BR><BR>};<BR><BR>//
离开游戏<BR><BR>if (c == exitCmd)
{<BR><BR> destroyApp(false);<BR><BR> notifyDestroyed();<BR><BR>};<BR><BR>//
开始游戏<BR><BR>if (c == startCmd)
{<BR><BR>theGame.removeCommand(startCmd);<BR><BR>theGame.addCommand(restartCmd);<BR><BR>theGame.restart();<BR><BR>};<BR><BR>//
确定<BR><BR>if (c == OKCmd) {<BR><BR>Form f = (Form)d;<BR><BR>Gauge g
=
(Gauge)f.get(0);<BR><BR>theGame.setLevel(g.getValue());<BR><BR>Display.getDisplay(this).setCurrent(theGame);<BR><BR>};<BR><BR>//
取消<BR><BR>if (c == cancelCmd)
{<BR><BR>Display.getDisplay(this).setCurrent(theGame);<BR><BR>};<BR><BR>//
打开音效<BR><BR>if (c == audioOnCmd) {<BR><BR>/* 打开音效
*/<BR><BR>theGame.createAudioPlayer();<BR><BR>theGame.removeCommand(audioOnCmd);<BR><BR>theGame.addCommand(audioOffCmd);<BR><BR>};<BR><BR>//
关闭音效<BR><BR>if (c == audioOffCmd) {<BR><BR>/* 关闭音效
*/<BR><BR>theGame.destroyAudioPlayer();<BR><BR>theGame.removeCommand(audioOffCmd);<BR><BR>theGame.addCommand(audioOnCmd);<BR><BR>}<BR></P></TD></TR></TBODY></TABLE></SPAN><BR><BR></DIV></TD></TR>
<TR>
<TD class=center01>
<DIV align=center>来源:天极网 作者:
<DIV></DIV></DIV></TD>
<TD class=center01 width=280>
<DIV align=center><FONT color=#0000ff><A
href="http://act.it.sohu.com/book/chapter.php?id=461&volume=4&chapter=13">上一页</A></FONT>
<FONT color=#0000ff><A
href="http://act.it.sohu.com/book/serialize.php?id=461">回书目</A></FONT>
<FONT
color=#0000ff>至末页</FONT>
</DIV></TD></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD width=760>
<TABLE height=10 cellSpacing=0 cellPadding=0 width=760 border=0>
<TBODY>
<TR>
<TD></TD></TR></TBODY></TABLE><!------------ 评论 ---------------->
<TABLE cellSpacing=0 cellPadding=0 width=760 border=0>
<TBODY>
<TR>
<TD><IFRAME id=vs src="用MIDP实现贪吃蛇游戏(3).files/comment_list1.htm"
frameBorder=0 width="100%"
scrolling=no></IFRAME></TD></TR></TBODY></TABLE><BR>
<SCRIPT language=javascript>function CheckNetwordForm(theForm){ if("" == theForm.content.value) { alert("写两句吧~~"); theForm.content.focus(); return false; } var index; for(index=0;index<theForm.content.value.length;index++) { if(" " != theForm.content.value.charAt(index)) break; } if(index == theForm.content.value.length) { alert("写两句吧~~"); theForm.content.focus(); return false; } if (theForm.content.value.length>100){ alert("评论字数不能超过100哦"); theForm.content.focus(); return false; } return true;}</SCRIPT>
<!------------------ 评论 --------------->
<FORM name=netword onsubmit="javascript: return CheckNetwordForm(this);"
action=insertnetword.php method=post>
<TABLE cellSpacing=0 cellPadding=0 width=760 border=0>
<TBODY>
<TR>
<TD class=text6 height=25> 给此书打分:<A name=1></A> <SELECT
name=score> <OPTION value=5 selected>非常好</OPTION> <OPTION
value=4>还凑合</OPTION> <OPTION value=3>一般吧</OPTION> <OPTION
value=2>不太行</OPTION> <OPTION value=1>太差了</OPTION></SELECT>
用户名: <INPUT id=id type=hidden value=461 name=id> <INPUT type=hidden
value=/book/chapter.php?id=461&volume=4&chapter=14
name=backurl> <INPUT id=username maxLength=20 name=username> <FONT
color=#666666>*评论字数请控制在一百字以内</FONT> </TD></TR></TBODY></TABLE><BR> <TEXTAREA id=description name=content rows=4 wrap=off cols=80></TEXTAREA>
<INPUT type=submit value=提交 name=Submit>
</FORM></TD></TR></TBODY></TABLE></TD></TR></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 border=0>
<TBODY>
<TR>
<TD width=1003 background=用MIDP实现贪吃蛇游戏(3).files/t_bj01.gif height=9><IMG
height=1 src="" width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=760 bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD>
<HR width=760 noShade SIZE=1>
</TD></TR>
<TR>
<TD align=middle><A class=black href="http://www.chinaren.com/"
target=_blank>ChinaRen</A> - <A class=black
href="http://big5.www.sohu.com/" target=_blank>繁体版</A> - <A class=black
href="http://hr.sohu.com/hrm.html" target=_blank>搜狐招聘</A> - <A class=black
href="http://add.sohu.com/" target=_blank>网站登录</A> - <A class=black
href="http://help.sohu.com/" target=_blank>帮助中心</A> - <A class=black
href="http://book.news.sohu.com/onClick=this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.sohu.com');return"
target=_blank false;>设置首页</A> - <A class=black
href="http://adinfo.sohu.com/" target=_blank>广告服务</A> - <A class=black
href="http://www.sohu.com/about/lianxi.htm" target=_blank>联系方式</A> - <A
class=black href="http://www.sohu.com/about/privacy.html"
target=_blank>保护隐私权</A> - <A class=black href="http://www.sohu.com/about/"
target=_blank>About SOHU</A> - <A class=black
href="http://www.sohu.com/about/" target=_blank>公司介绍</A><BR><SPAN
class=eng>Copyright © 2004 Sohu.com Inc. All rights reserved. 搜狐公司
版权所有</SPAN> </TD></TR></TBODY></TABLE></CENTER><!-- START NNR Site Census V5.1 --><!-- COPYRIGHT 2004 Nielsen // Netratings -->
<SCRIPT language=JavaScript type=text/javascript>
<!--
var _rsCI="cn-sohu";
var _rsCG="0";
var _rsDT=0;
var _rsDU=0;
var _rsDO=0;
var _rsX6=0;
var _rsSI=escape(window.location);
var _rsLP=location.protocol.indexOf('https')>-1?'https:':'http:';
var _rsRP=escape(document.referrer);
var _rsND=_rsLP+'//secure-cn.imrworldwide.com/';
if (parseInt(navigator.appVersion)>=4)
{
var _rsRD=(new Date()).getTime();
var _rsSE=1;
var _rsSV="";
var _rsSM=0.01;
_rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v51.js"><\/scr'+'ipt>';
}
else
{
_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
}
document.write(_rsCL);
//-->
</SCRIPT>
<NOSCRIPT><IMG alt="" src=""> </NOSCRIPT><!-- END NNR Site Census V5.1 -->
<SCRIPT language=JavaScript src="用MIDP实现贪吃蛇游戏(3).files/nnselect.js"></SCRIPT>
<NOSCRIPT><IMG height=1 src="" width=1> </NOSCRIPT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -