📄 基于nokia手机的移动游戏开发(5).htm
字号:
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>
<P>import javax.microedition.lcdui.*;<BR>import
com.nokia.mid.ui.*;<BR>public class HighScore extends FullCanvas
{<BR>private GameMIDlet parent = null;<BR>private MainMenu menu =
null;<BR>public HighScore(GameMIDlet parent, MainMenu menu)
{<BR>this.parent = parent;<BR>this.menu = menu;<BR>}<BR>protected
void paint(Graphics g) {<BR>//Paint the high scores
here<BR>}<BR>public void keyPressed(int keyCode) {<BR>if (keyCode !=
KEY_END) {<BR>//selection list to the
screen<BR>parent.setDisplayable(menu);<BR>}<BR>}<BR>}
</P></TD></TR></TBODY></TABLE>
<P><BR> 6
教学屏幕<BR><BR> 当用户从主菜单中选择"Instructions"条目的时候,就会显示出游戏的规则。游戏规则文本放置在Form实例中。Form中应该包含用于进入下一条教学规则的命令(例如,标签"More")和回到主菜单的命令(例如,标签"Back")。"More"一般由左功能键控制,而"Back"由右功能键控制。如果教学规则里包含动画,那么这些动画应该使用全屏画布(FullCanvas)来显示。按下左功能键将跳过动画进入下一个教学屏幕。按下右功能键,用户将从动画中回到主菜单。键End将结束应用程序。下面的代码是文字教学规则和动画的框架。<BR><BR></P>
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>
<P>//Text instructions. Text can be written in constructor or in
own<BR>method.<BR>//Developer should remember that also instruction
texts should be<BR>//internationalized<BR>import
javax.microedition.lcdui.*;<BR>public class Instructions extends
Form implements CommandListener {<BR>//Command for going next
instruction if needed<BR>private Command more = new
Command(<BR>Resources.getString(Resources.ID_GAME_MORE),<BR>Command.OK,
1);<BR>//Command for going back to the main menu<BR>private Command
back = new Command("", Command.BACK, 2);<BR>private GameMIDlet
parent = null;<BR>private MainMenu menu = null;<BR>public
Instructions(String title, GameMIDlet parent, MainMenu<BR>menu)
{<BR>super(title);<BR>this.parent = parent;<BR>this.menu =
menu;<BR>this.addCommand(back);<BR>this.addCommand(more);<BR>this.setCommandListener(this);<BR>}<BR>public
void commandAction(Command p0, Displayable p1) {<BR>if (p0 == more)
{<BR>//go to the next if needed e.g
animation<BR>parent.setDisplayable(new
InstructionAnimation(parent));<BR>}<BR>else if (p0 == back)
{<BR>parent.setDisplayable(menu);<BR>}<BR>}<BR>}<BR>//Instruction
animation<BR>import javax.microedition.lcdui.*;<BR>import
com.nokia.mid.ui.*;<BR>public class InstructionAnimation extends
FullCanvas {<BR>private GameMIDlet parent = null;<BR>public
InstructionAnimation(GameMIDlet parent) {<BR>this.parent =
parent;<BR>}<BR>protected void paint(Graphics g) {<BR>//Do the
animation here<BR>}<BR>public void keyPressed(int keyCode) {<BR>if
(keyCode == KEY_SOFTKEY1) {<BR>//go to the next instruction screen
if needed<BR>}<BR>else if (keyCode == KEY_SOFTKEY2) {<BR>//selection
list to the screen<BR>parent.setDisplayable(new
MainMenu(<BR>Resources.getString
(<BR>Resources.ID_GAME_NAME),<BR>List.IMPLICIT,
parent));<BR>}<BR>}<BR>}</P></TD></TR></TBODY></TABLE>
<P><BR> 7关于(About)屏幕<BR><BR> 关于(About)屏幕显示游戏制作公司的消息文本或标志。当用户从主菜单中选择"About"选项的时候,就会启动这个屏幕。和教学规则页面一样,关于屏幕页面如果只需要文本信息的话,那么可以使用Form来实现。如果需要图像或动画,那么应该使用Canvas或FullCanvas。<BR><BR></P>
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>
<P>//Text "About" code skeleton<BR>import
javax.microedition.lcdui.*;<BR>public class About extends Form
implements CommandListener {<BR>//Command for going back to the main
menu<BR>private Command back = new Command("", Command.BACK,
1);<BR>private GameMIDlet parent = null;<BR>private MainMenu menu =
null;<BR>public About(String title, GameMIDlet parent, MainMenu
menu) {<BR>super(title);<BR>this.parent = parent;<BR>this.menu =
menu;<BR>this.addCommand(back);<BR>this.setCommandListener(this);<BR>}<BR>public
void commandAction(Command p0, Displayable p1) {<BR>if (p0 == back)
{<BR>parent.setDisplayable(menu);<BR>}<BR>}<BR>}</P></TD></TR></TBODY></TABLE>
<P><BR> 8 退出<BR><BR> 从主菜单中选择"Exit game"选项来中止游戏并释放所有的资源。 <BR><BR> 9
Resources类<BR><BR> Resources类不是一个用户界面类,与本文中介绍的其他类不同。这个类处理国际化问题。<BR><BR></P>
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>
<P>/**<BR>* A simple class to simulate a resource bundle.<BR>*
Modify the contents of this class according to the<BR>*
locales/languages you want your application to support.<BR>* In your
application, retrieve a string using code such as the<BR>*
following:<BR>* <pre><BR>* <code>String s =
Resources.getString(Resources.ID_GAME_NEW);<BR>*
</code></pre><BR>* Copyright (C) 2002 Nokia
Corporation<BR>*/<BR>public class Resources {<BR>// Identifiers for
text strings.<BR>public static final int ID_GAME_NEW = 0;<BR>public
static final int ID_GAME_OPTIONS = 1;<BR>public static final int
ID_GAME_HIGHSCORES = 2;<BR>public static final int
ID_GAME_INSTRUCTIONS = 3;<BR>public static final int ID_GAME_ABOUT =
4;<BR>public static final int ID_GAME_CONTINUE = 5;<BR>public static
final int ID_GAME_BACK = 6;<BR>public static final int ID_GAME_MORE
= 7;<BR>public static final int ID_GAME_EXIT = 8;<BR>public static
final int ID_GAME_LEVEL = 9;<BR>public static final int
ID_GAME_SOUNDS = 10;<BR>public static final int ID_GAME_VIBRA =
11;<BR>public static final int ID_GAME_NAME = 12;<BR>// List of
supported locales.<BR>// The strings are Nokia-specific values<BR>//
of the "microedition.locale" system property.<BR>private static
final String[] supportedLocales = {<BR>"en", "fi-FI", "fr",
"de"<BR>};<BR>//NOTE: default language must be the first
one<BR>//for getString to work!<BR>// Strings for each locale,
indexed according to the<BR>// contents of
supportedLocales<BR>private static final String[][] strings = {<BR>{
"New game", "Settings", "High scores",
"Instructions",<BR>"About","Continue", "Back", "More", "Exit
game",<BR>"Level", "Sounds","Shakes", "Game name" },<BR>{ "Uusi
peli", "Asetukset", "Huipputulokset",
"Peliohjeet",<BR>"Tietoja","Jatka", "Poistu", "Jatka",
"Poistu",<BR>"Vaikeusaste", "Peli??net",
"V?rin?tehosteet",<BR>"Pelin nimi" },<BR>{ "Nouveau jeu",
"Paramètres", "Scores", "Instructions",<BR>"A propos","Continuer",
"Retour", "Suite", "Sortir",<BR>"Niveau", "Sons", "Vibrations", "Jeu
nom" },<BR>{ "Neues Spiel", "Einstellungen", "Rekord",
"Anleitung",<BR>"über","Weiter", "Zurück", "Weiter",
"Beenden",<BR>"Ebene", "Ton", "Vibrationen", "Spiel name"
}<BR>};<BR>/**<BR>* Gets a string for the given key.<BR>* @param key
Integer key for string<BR>* @return The string<BR>*/<BR>public
static String getString(int key) {<BR>String locale =
System.getProperty("microedition.locale");<BR>if (locale == null)
{<BR>locale = new String(""); // use empty instead of
null<BR>}<BR>// find the index of the locale id<BR>int localeIndex =
-1;<BR>for (int i = 0; i < supportedLocales.length; i++) {<BR>if
(locale.equals(supportedLocales[i])) {<BR>localeIndex =
i;<BR>break;<BR>}<BR>}<BR>// not found<BR>if (localeIndex == -1)
{<BR>// defaults to first language, in this example
English<BR>return strings[0][key];<BR>}<BR>return
strings[localeIndex][key];<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=10">上一页</A></FONT>
<FONT color=#0000ff><A
href="http://act.it.sohu.com/book/serialize.php?id=461">回书目</A></FONT>
<FONT color=#0000ff><A
href="http://act.it.sohu.com/book/chapter.php?id=461&volume=4&chapter=12">下一页</A></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="基于Nokia手机的移动游戏开发(5).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=11
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=基于Nokia手机的移动游戏开发(5).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="基于Nokia手机的移动游戏开发(5).files/m.gif"> </NOSCRIPT><!-- END NNR Site Census V5.1 -->
<SCRIPT language=JavaScript
src="基于Nokia手机的移动游戏开发(5).files/nnselect.js"></SCRIPT>
<NOSCRIPT><IMG height=1 src="" width=1> </NOSCRIPT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -