|
|
开发手机游戏其实并不神秘,反而要比传统PC游戏更没有技术门槛,原因在于PC上已有的技术积累,成熟开发模式的重用,以及设备的局限性,简化了手机游戏的开发过程
在哪里开发?
不用担心,不用什么设备,电脑一台,测试手机一部足矣...自己学习的话,没有手机也没什么大不了
配置环境:
建议netbeans
安装java.sun.com上的jdk+netbeans套装
再到www.netbeans.org下个netbeans mobile pack
装好就行
( elipseMe实在是个不太成熟的东西,不推荐 ,netbeans实在太容易装了,elipseMe实在太难装了*_*)
基本概念:
j2me是java的一个子集,手机开发是j2me的一个子集
java > j2me > 手机开发(CLDC设备)
CLDC,翻过来叫做 " 有限连接设备配置 ",是对移动设备的一种定义.而手机正是符合这种定义的设备之一
CLDC定义了我们能够使用的最基本的类与方法
-------------------------------------------------------------------------------------------------
请注意CLDC有1.0和1.1之分,最主要的区别在于1.1支持浮点数 ,支持CLDC1.1也是高端手机的一种象征( 这种手机较少,如NOKIA 6155 )
对于这一点请别吃惊,由于没有浮点寄存器,很多手机对浮点数的运算很慢
-------------------------------------------------------------------------------------------------
MIDP,翻过来叫做移动信息设备框架(怎么都那么别扭啊).是她给予我们控制手机的各种方法,比如自定义的窗口,游戏的画面,声音等
( 对于一个新手,这两样是基础,学会这两个,基本上能做简单游戏了 )
请看清楚你的手机是怎样支持java的
比如NOKIA 6250是JAVA这样被支持的
CLDC 1.0
MIDP 1.0
Nokia UI API
因此如果你使用了浮点数,或者声音(只有MIDP 2.0才支持声音 )那么你的手机就会抗议了
开始编程:
这是一个netbeans模版例子,新建一个netbeans的project,选moile application,一路点是...
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* An example MIDlet with simple "Hello" text and an Exit command.
* Refer to the startApp, pauseApp, and destroyApp
* methods so see how each handles the requested transition.
*/
public class HelloMIDlet extends MIDlet implements CommandListener {
private Command exitCommand; // The exit command
private Display display; // The display for this MIDlet
public HelloMIDlet() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
/**
* Start up the Hello MIDlet by creating the TextBox and associating
* the exit command and listener.
*/
public void startApp() {
TextBox t = new TextBox("Hello MIDlet", "Test string", 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);
display.setCurrent(t);
}
/**
* Pause is a no-op since there are no background activities or
* record stores that need to be closed.
*/
public void pauseApp() {
}
/**
* Destroy must cleanup everything not handled by the garbage collector.
* In this case there is nothing to cleanup.
*/
public void destroyApp(boolean unconditional) {
}
/*
* Respond to commands, including exit
* On the exit command, cleanup and notify that the MIDlet has been destroyed.
*/
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
跑跑看,是不是挺爽的
好了,接下来去买本j2me编程的书来看看,或者网上王森大哥有一本Java手机程序设计入门,可以免费下载(因为书商不给卖了,狠哪),MIDP specification也必不可少,这个在java.sun.com下载到wtk22这个包里面有
编程做完后才是最麻烦的,拿到各种模拟器上测试,做不同手机的不同版本,拿到真机上测试......天呢,不过现在还不用担心这个
记住下面的网站
http://www.j2megamer.com/
http://www.benhui.net/......想学手机3D怎么做?看!
http://www.csdn.net......社区的j2me版人气不错,水平也高
http://www.cn-java.com
http://www.cnjm.net
http://www.forum.nokia.com/.......nokia官网,必去
http://developer.sonyericsson.com/......看名字就知道
http://www.motocoder.com/......看名字就知道
http://www.siemens.com/developers......看名字就知道
http://developer.samsungmobile.com/......看名字就知道
作者:wingser
授权:可任意修改转贴,请保留原作者名 |
|