游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

手机游戏开发趋势和J2ME API相关概览

发布时间:2011-07-14 23:34:33 Tags:,,

游戏邦注:本文原作者是德州大学奥斯汀分校的博士研究生Michael Yuan,他在本文中畅谈J2ME和手机应用程序。目前,他领导构建一系列针对Nokia开发者平台的计划项目。

纵观整个IT产业的发展史,电脑游戏已经成为技术创新背后的一股强大的驱动力。电脑游戏玩家渴望更强的硬件运算能力;迫切于拓展各种软件的界限——从引人注目的图形到人工智能(AI),再到网络安全。游戏开发者和玩家往往是采纳前沿计算机技术的先锋。因为其创新本质,游戏才不致于沦为被几个大型外包企业所掌控的科技产品。有才能的独立创意人在这片领域总有大片生存发展空间。

随着技术不断提升游戏体验,游戏市场还会继续成长壮大。IT行业革命节省了我们的时间和资金,从而延长了我们的工作时限;同时,我们把更多的时间和资金花在游戏上,从而提升了生命的总体质量。即使是在当前的经济困难大背景之下,游戏行业依然保持迅猛的增长势头,仍然是赢利的产业部分。Java开发者不应忽视其巨大的机遇所在。

而在IT行业的其他部分,游戏业的新贵应属手机游戏。手机游戏已经将许多原本不可能的行业参与者汇聚在一起,这些参与者包括:传统企业(如美国的太阳微系统公司的新游戏部门)、设备制造商(如诺基亚的游戏手机和美国高通公司的无线二进制运行环境设备)和网络经营商(如英国的沃达丰公司的信息服务)。

因为Java2平台,Micro Edition (J2ME)正兴起成为最受广泛支持的手机游戏平台之一,作为Java开发者,我们也应该积极适应这个有利可图的新产业部门。在本文,我将从Java开发者的角度解读手机游戏面临的机遇与挑战;同时,我还根据几项重要的J2ME技术规范对艺术手机的Java技术做出几点概述。

手机游戏特征

手机游戏的商业号召力来自其广泛的影响力。手机已经融为与现代生活紧密结合的一部分。除了钥匙和钱包,手机就是人们出行最常携带的个人物品。不像传统的游戏机游戏(游戏邦注:它们主要吸引游戏宅人和青少年),任何人在任何时间、任何地方都可以玩上一把手机游戏。尽管每款手机游戏都很廉价,但其庞大的消费量(如每人每周消费一个新游戏)足以开拓出巨大的市场、创造可观的利润。然而,对于开发者而言,因为二者之间天差地别的目标受众、品位和营销模式,手机游戏与游戏机游戏相比,呈现了重大的模式转变。

先决条件

一款成功的手机游戏一般至少具有以下特征之一:

易上手:因为手机游戏面向普通用户,而不是电脑通。普通大众是不可能一下子就上手一款游戏。用户也不会在学习一款游戏的操作指南上花太多时间。所以保证游戏简单、易上手是必要的。

可中断性:多重任务是手机游戏的基本特征。一款手机的用户通常在几个小活动之间(游戏邦注:如等邮件或的士)有较小的时间空档。同一个设备要支持的不止是游戏,还有日程管理、收发信息和工作数据等。一款优秀的手机游戏应该能提供短期的娱乐价值,同时允许用户在游戏和工作模式之间自由流畅转换。

认购基础:手机游戏的商业成功取决于庞大的消费量。从头到尾完整地设计开发出一款游戏,其成本是不低的。对于想挣钱的手机游戏开发者,以相同的引擎、相似的基础剧情,打造不同类型的游戏就相当重要了。以认购为基础的游戏是产生持久收益的最好方式。

丰富的社交互动:无论是多么卓越的游戏设计,如果玩家摸清了游戏内在特征或者玩遍所有可玩的路线,这款游戏也就变得不那么有意思了。对于以认购为基础的游戏,整合其他玩家,以增加游戏的智能性与随机性,是至关重要的。在许多大型多人游戏的成功都归功于丰富的社交互动。

利用手机创新技术:大量的手机技术研究经费被投放到增强设备和网络的实用性和可靠性中。因此,移动设备软件和网络协议是不同于桌面或游戏机世界(如GPS拓展、条形数码扫描仪、短信服务(SMS)或彩信服务(MMS))的。优秀的手机游戏应该充分利用这些创新设备的特点和网络基础设施。

隐藏内容:因为所有年龄和所有性别的群体都会玩手机游戏,且通常在公共或工作场所,所以要避免太明显的暴力和与性相关的内容。

手机游戏类型

基于以上标准,大多数成功的手机游戏的发展势头该是这样的:休闲性、为处于所有社交场合的广泛群体提供娱乐价值。特别要注意的是,以下几类游戏将成为日后的重头游戏:

多人游戏:这类游戏能开启进入已有的在线游戏社区的移动通路。或者,他们可以利用手机特有的特点,如多媒体信息和当地服务,创造完全不同的社交结构。优秀的游戏设计和管理对这类型游戏的成功必不可少。

剧情游戏:这类游戏将版权多媒体娱乐内容,例如名人图片、视频、语音铃声和个性化的体育游戏传输给音乐、电影、体育粉丝。成功的关键是源源不断地提供与其订阅成本相当的高质量内容。

高视觉效果游戏:电脑游戏和游戏机游戏已经从2D演变至3D。手机游戏也将沿着这种趋势发展。目前已经存在几款手机3D工具包和手机。不过,3D游戏毕竟是资源集约型游戏,所以需要组合开发者和图形设计师双方的专业技术。专业开发商非常有可能创建这类游戏。

在手机游戏的发展早期,大多数开发者都热衷于使用设备、学习新技术、快速获取收益。然而,随着越来越多的开发者涌入这个手机游戏领域,该行业就演变为涉及专业设计师、建筑师、开发者、营销商、律师和艺术家等等人物的重要产品。这是游戏行业成熟化过程中不可避免的发展趋势。对于开发者,这种改变带来的是挑战,也是机遇。当个人利用空闲时间开发和出售简单的游戏变得越来越困难时,更多应用商店将为许多人提供更好的就业机会。

手机价值链

为了充分理解手机游戏的发展前景,你必须先理解资金流的运作。这种商业价值链与传统的游戏或者程序相当不同。

开发者:软件开发者通过创造应用程序来操纵价值链。然而,大多数开发者并不具有掌控大规模市场营销的能力。他们也缺少直达消用户的营销渠道。

发行商:游戏发行商集合来自各方开发者的游戏。他们建立起品牌名称、确保游戏技术的正确性、促销游戏、和无线运营商建立商业联系。发行商还要代表开发者处理订单,且往往与开发者共享收益。

无线运营商:无线运营商在手机游戏的销售渠道中处于中心地位。运营商不仅控制了网络,还拥有客户信息。支持什么设备和服务取决于运营商。运营商切走了赢利蛋糕中最大的一块。运营商还通过现存的服务协议向用户收费。

无线设备制造商:设备制造商推动着技术创新。他们制作新硬件、支持平台的发展。事实上,J2ME的成功很大程度上是因为主要设备制造商的创新。设备制造商代表了介于运营商与用户之间的独立力量。

用户:用户最终支付成本和这条价值链相关的利润。用户可以从发行商的网站上或通过由运营商提供的内容供应系统购买游戏。

价值链

价值链

J2ME智能客户端

J2ME平台已成为最重要的手机游戏平台,被开发者、设备制造高、网络营销商和用户广泛接受。该平台的几个特点能使四方皆受益。

智能客户端的特征

J2ME设备是智能化的。它们可以自行处理信息。将J2ME智能手机与前代区别开来的最重要特征是:

对于用户,一台智能手机的最吸引人的特点莫过于可以在持续网络联接的情况下玩游戏。当下的2-2.5G网络,其覆盖面呈分散状,且信息流量转昂贵,离线模式因而是必要的。缓存数据和队列网络运作的能力极大地缓合了无线网络的拥挤且增强了程序的可靠性。

智能客户端可以将后台游戏服务与平行部分(无线运营商和互联网对等机)通过各种协议相结合。

智能客户端支持丰富的用户界面(UI),这种UI的主要特征是画面吸引人。

智能客户端可以接入手机特有的网络(如SMS和MMS)或设备拓展(如GPS)特征。这使得开发充分利用移动生活风格的的游戏成为可能。

通于先进的加密术和数字签名算法,智能客户端带来了更强大更灵活的安全性。对于智能客户端,在网上传输敏感的用户个人数据,并且建立有效的在线社区也成为可能。

便携式平台

与其他智能客户端平台相比,J2ME具有独一无二的优势:移动性。不同设备数量的庞大,导致移动设备的市场竞争激烈,J2ME应用程序适用于为数众多的设备就显得极其重要了。所有主要的智能手机制造商都已下定决心支持J2ME平台。对于想要保持单一代码库但尚未最大化用户人数的开发者而言,代码可移植特征的重要性不容忽视。

J2ME解决了“最低共统区”的难题,因为其定义了由配置、配置文件和选项包组成的多层结构,所以困扰了桌面Java许多年。到目前为止,在手机游戏行业,最流行的J2ME平台是移动信息设备配置文件(MIDP)和基于MIDP的可选包。在本文,我将着重探讨MIDP v2平台。

J2ME结构

J2ME结构

因为J2ME应用程序在各种设备之间都具有可移动性,所以它们通常是在网络上下载后执行。如果没有必要的措施,这种行为对用户和无线运营商都会带来巨大的安全风险。所幸的是,Java经过设计后算是一种安全的语言。所有比特代码类的应用程序都在之前的执行中证明了这点。Java虚拟机(JVM)可监测应用程序在执行过程中的安全和存储非法情况。MIDP v2的运行环境包括一个功能完整、以域名为基础的安全管理器,该管理器授予API级的许可给基于数字签名的ID程序。

因为J2ME的广泛运用,手机Java开发者支持已经成长为一个相当大的市场。几乎所有流行的Java开发工具已经满足了J2ME开发者的需要。J2ME libraries和组件准备向第三方供应者开放。许多这些libraries为他们的J2SE(Java 2 Platform, Standard Edition)提供类似的功能。例如,IBM服务管理框架(SMF)技持在掌上电脑的Java 小服务程序;PointBase Micro Edition为手机相关数据库提供JDBC(Java Database Connectivity)式通路;IAIK JCE-ME支持轻型加密扩展(JCE)版本。这些工具和libraries使得J2SE开发者把技术移植到手机平台更加容易。然后,又为J2ME供应商创造了大量开发者基础。积极的反馈循环有助于J2ME的成长。

API(应用程序界面)和工具的概述

在下面这部分,我概述了J2ME游戏相关的API,并且检查了其对开发者的可用性。

用户界面(UI)

MIDP运行环境对手机屏幕和软件密钥进行严密的控制。所有MIDP UI 类都是来自javax.microedition的可显示界面:

屏幕类是高级UI小工具(如Alert, List, Form, and TextBox)的基础。MIDP运行环境控制如何展示这些高级的UI类和如何根据特定设备的UI惯例分配动作铵钮。MIDP高级小工具对文本控件最适用。在高级UI类中,Form类是使用最灵活的。可以指定Form屏幕的布局、添加StringItem、 TextField、DateField, ChoiceGroup和Gauge等小控件。

MIDP v2规范给高级UI带来了两样重要革新:一是允许文本和图形展示通过引入Spacer 和ImageItem,在同一个Form上混合使用;二是为开发者通过CustomItem类设计和执行项目级的小工具提供了一种机制。开发者极大地控制了包括像素级绘图和内部事件处理在内的CustomItem对象。

画布类是低级MIDP UI的基础。它提供了访问整个屏幕和自定义映射上的象素级绘图的所有硬件按钮。你可以只做一个画布的子集和覆盖paint()来展示标志;而keyPressed(),、keyRepeated()和keyReleased()可以触发关键事件; pointerPressed()、pointerDragged()和pointerReleased()可以用于指示和触发触屏笔事件。

游戏画布继承了画布类,是MIDP v2游戏API的一部分,且为游戏开发提供了方便的机制。例如,在游戏画布子集,每次调整都不必覆盖paint()就可以画出整个屏幕。可以直接通过getGraphics()获得Graphics对象,然后利用。当需要更新演示时,可以使用flushGraphics()(当然,此法只能更新一部分屏幕)。与画布类的单一paint()方法相比,游戏画布使我们可以更容易地保持图形状态和快速更新屏幕的动画部分。与此类似,游戏画布类也提供了便利的方法来通过getKeyStates()(而不是画布类的callback)测试铵钮状态。这就使得复杂的游戏屏幕类别的执行更加灵活。

MIDP UI 结构

MIDP UI 结构

MIDP v2规范给javax.microedition.lcdui.游戏包中的游戏程序定义了一整个API。除了游戏画布类,还提供了支持平铺和动态化游戏背景影像的Layer类。游戏API还有子画面(Sprite)类来处理人物和爆炸效果的动画化。对于2D画形游戏,这些都是必要组成部分。在3D方面,JSR (Java Specification Request184)规范试图标准化手机上的Java 3DAPI。目前已取得了长足的进步。J2ME 3D工具在SuperScape(一款虚拟现实应用程序的软件开发工具)中已经可用。大型设备制造商也加快发展步伐,以支持高端智能手机设备上的新API。

SuperScape的Java 3D游戏举例

SuperScape的Java 3D游戏举例

除了标准MIDP UI 和游戏API,还存在几个其他MIDP UI 工具箱。它们既提供针对某个设备装置的功能,也支持游戏开发中的高级UI的改善。

Nokia手机游戏的UI 安装包提供了声音、光照和振动部分的控件,对于更专业的游戏,它还支持真实全屏模式。

Motorola轻型小工具(LWT)是服务于Motorola手机的独立方窗体工具箱。

OWT(The Nextel Open Windowing Toolkit)是由Motorola和Nextel联合开发的开源工具箱。它带有包含模式来控制布局和其他UI组件(这些对桌面UI 开发者来说应该不陌生)。OWT以画布类别为基础,在所有MIDP手机上可运行。然而,如果使用OWT库,请保证把它纳入配送MIDlet组件。

Synclast UI工程开发是一个开放资源 UI 程序包,可支持容器模式。因其以MIDP v1画布类为基础,所以还支持许多MIDP v2 小工具。因此,它还允许MIDP v2程序在当下的微修改后的MIDP v1 设备上运行。要使用OWT,必须将Synclast libraries捆绑入分布式应用。
总之,MIDP平台为UI游戏选择提供了各种丰富的选择。

网络和后台集成

如前所述,手机游戏的未来发展目标是网络多人游戏。J2ME的网络化将以通用联接框架(GCF,Generic Connection Framework)作为支撑。GCF的核心是一个工厂类javax javax.microedition.io.Connector。通过协议和地址伸展至静态方法Connector.open(),以获取链接远程主机的连接对像:

HTTP协议支持在MIDP是是强制性的。如果通过http://hostname:port连接字符串到Connector.open(),就会返回一个HttpConnection对象。可以在接连上直接打开输入或输出(I/O)数据流,也可以在远程主机上写入数据或从远程主机上接收数据。

在一些实现中,Unix接口、用户数据报协议(UDP,User Datagram Protocol)连接或直接的TCP/IP连接也是支持的。值得注意的是,手机网络与有线互联网从根本上说是不相同的。一些网络在HTTP层面上模仿接口接连。所以,直接接口在表现上未必能产生更好的收益。在此我推荐多使用HTTP。

J2ME无线信息传送API (WMA)支持手机在CGF上的SMS信息传送。可以发送SMS信息到另一部正在使用MessageConnection(从sms://phone_number:port连接字符串获取)对象的手机上。还可以打开一个感应传入的SMS信息“服务器”接连(使用sms://port string)
传入的SMS信息可以由synchronously 或 asynchronously处理。

在MIDP v2中,可以用由MIDP v2运行环境管理的推注册申请“服务器”SMS 连接。这样,在信息抵达时,开发者可以调用MIDlet来处理信息。

除了协议层面,J2ME支持几种方法来通过构成的应用程序数据:

MIDP DataInputStream和DataOutputStream类别支持用Java的便利I/O方式(如writeInt()、 writeUTF()、writeFully()等和相应的 readXXX() 方式)来序列化共用数据价值和对象。在通信信道两侧使用成对的writeXXX() 和readXXX()方法可以极大地简化开发者的工作量,同时增加端对端的应用程序的稳定性。

如果需要更多结构性数据交换,MIDP平台还支持几种XML分析程序。可拓展标记语言(XML)分析程序支持Simple API for XML (SAX)、XmlPull和轻型文件对象模式(DOM)解析范例的单一API。JSR172(J2ME Web Services Specification)正在为J2ME开发一种标准化的XML分析程序API。

基于简单对象访问协议(Simple Object Access Protocol (SOAP))的网络服务器是端对端整合方案的发展方向。J2ME平台也支持通过第三方工具箱(如kSOAP)和标准化API(如JSR172)进行的SOAP信息交换。

数据管理

设备上的数据管理是智能客户端的核心特点。J2ME在这方面有强大的支柱:

MIDP上的标准数据留存设备是记录管理服务(Recordstore Management System (RMS))。它并不允许随机访问或任何分层数据结构。但它提供有限的功能来达到存储和整理搜索结果的目标。

在所有MIDP设备上,RMS都是强制性的。但是,MIDP本身并不提供API来同步RMS数据和后台程序。JSR230(Data Sync API)只是刚开始发展这种同步性的API。

JSR75(PDA Optional Packages for J2ME)允许使用设备的本机个人信息管理(PIM)程序(如日程表通讯簿、电邮和计划表等)和文件系统。PIM数据和文件可以通过设备的本机同步组件来同步到电脑上。

对于更复杂的数据,你可以使用移动数据库。几种商业化的MIDP数据库(相关的和对象方向的)和同步引擎在MIDP平台上是可用的。

多媒体

多媒体播放功能对内容导向型手机娱乐程序很重要。J2ME多媒体API(JSR135)是为播放多媒体内容而制定的J2ME的标准框架。通过玩家界面,可以播放多来自各自不同数据资源的声音和影像格式。多用途互联网邮件扩展(Multipurpose Internet Mail Extensions (MIME))类型在运行时传给玩家用于指定内容格式。每一种设备的多媒体API的执行都支持不同的MIME类型组(由硬件和本机玩家能力决定)。当前,几乎所有的多媒体API兼容的设备都支持简单的铃声播放,而支持如MP3、3GPP甚至是MPEG4等更复杂的格式也指日可待。

安全

手机游戏涉及下载代码、版权内容和商业交易。为了保护用户、开发者、发行者和运营商的利益,安全工作不可掉以轻心,特别是多人游戏(一些用户会为了寻找漏洞而攻击系统)。J2ME在申请和通信安全方面都提供了良好的支持。

MIDP v2规范支持使用开发者或经销商的数字证书的申请认证。基于认证者的身份(安全域名),运行环境安全管理器可以给申请授予API级访问权限。例如,一个来自不受信任来源的申请可能无法进行网络连接或发送SMS信息。

JSR177(Security and Trust API for J2ME)规范了嵌入在设备中的硬件安全基础(如用户身份组件(SIM)卡)。如,它允许J2ME开发者恢复储存在SIM卡上的数字证书或使用硬件加速的加密算法。

供应和销售

手机游戏传输到消费者的过程是复杂的,涉及许多方面。MIDP规范包括了关于空中下载技术(OTA)的内容。它描述了如何通过WAP网络下载一款MIDP游戏、Java程序管理软件(AMS)应该如何安装和生效程序。空中下载过程给客户端设备提供一种反馈机制,用于报告安装状态。它为更复杂的商业发布过程提供了技术基础。在商业方面,几个重要的过程应该考虑到:

应用程序必须保证无病毒且得到运营商支持。不同的客户端设备应该提供不同的Java归档文件夹,以保证最大化利用设备的能力(图形和安装选项包)。

处理好客户帐单和开发者的付款。直接从手机上运行点击支付系统极其重要。

运营商和发行商已经可以使用几种商业供应法。JSR124 (Java 2 Platform, Enterprise Edition (J2EE) Client Provisioning Specification)旨在通过定义一个通用的J2EE框架,为客户端调度来规范这些方法。在该框架中,不同的空中下载规范的插件程序、用户跟踪方案和帐单服务得以发展和协作。J2ME的商业成功离不开这些努力。

J2ME客户端供应规范结构

J2ME客户端供应规范结构

总结

在本文,我解释了为什么休闲多人手机游戏会是游戏产业的未来发展方向。手机设备制造商已经看到了这个巨大的机遇,也已经推出针对手机游戏的设备(如Nokia N-Gage)。J2ME或MIDP已成为最重要手机游戏设备和智能机的技术平台之一。阅读完本文,大家应该明白J2ME在手机游戏方面的优势和弱势所在。(本文为游戏邦/gamerboom.com编译,如需转载请联系:游戏邦

Develop state-of-the-art mobile games

Trends in mobile games and a survey of related J2ME APIs

By Michael Juntao Yuan

Throughout the IT industry’s history, computer games have been one of the drivers behind technology innovations. Computer gamers are hungry for more hardware computing power; they are eager to push the limits of various software—from compelling graphics to artificial intelligence (AI) to network security. Game developers and players are often the earliest adopters of leading-edge computer technologies. Due to their innovative nature, games are not in danger of becoming technology commodities controlled by big outsourcing corporations—there is always plenty of room for talented individual innovators in this space.

The market for games will continue to grow as the technology enhances the playing experience. As the enterprise IT revolution improves our work life by saving time and money, we spend more time and money on games to improve the general quality of life. Even in today’s difficult economic times, gaming remains a fast growing and profitable industry sector. Java developers should not overlook the tremendous opportunities here.

As in the rest of the IT industry, the latest buzz in the game industry is mobility. Mobile games have brought together many unlikely players from traditional enterprise companies (e.g., Sun Microsystems’ new game division), equipment manufactures (e.g., Nokia’s N-Gage and Qualcomm’s Brew devices), and network operators (e.g., Vodafone’s content services).

As Java developers, we are well suited to enter this profitable new industry sector because the Java 2 Platform, Micro Edition (J2ME) is emerging as one of the most widely supported mobile gaming platforms. In this article, I discuss the opportunities and challenges of mobile gaming from a Java developer’s perspective. I also survey state-of-the-art mobile Java technology through important J2ME specifications.

Mobile game characteristics

Mobile games’ financial appeal comes from their wide reach. Mobile phones have become tightly integrated into the modern lifestyle. They are second only to keys and wallets as the most commonly carried personal items. Unlike traditional console games that target geeks and teenagers, mobile games are accessible to anyone—anywhere, anytime. Although each mobile game is inexpensive, the projected large volume (e.g., a new game per week per person) will make this market immense and profitable.

However, for developers, mobile games present a big paradigm shift from console games due to the vastly different target audience, lifestyle, and distribution models.

Let’s start with mobile games’ requirements.

Requirements

A successful mobile game will likely have one of the following characteristics:

Easy to learn:Since mobile games target general consumers not computer-savvy techies, they cannot have steep learning curves. Consumers will not spend hours studying an operation manual of a game. The game must be playable the moment it is downloaded. It is essential to keep the game simple.

Interruptible:Multitasking is a basic characteristic of the mobile lifestyle. A mobile user often has small chunks of free time available between tasks (e.g., while waiting for an email or a taxi to arrive). The same device is used for games, calendar management, messaging, and work data access. A good mobile game should provide entertainment value for short time periods and allow users to switch smoothly between game and work modes.

Subscription based:Mobile games’ financial success depends on their large volume. It is expensive to design and develop each game from scratch. For a mobile game developer to make money, it is important to offer multiple titles from the same game engine along similar basic storylines. Subscription-based games are the best way to generate sustained revenue.

Rich social interactions:No matter how good a game design is, it quickly becomes boring when the player figures out the underlying pattern or has exhausted all the play routes. For subscription-based games, it is important to incorporate other human players to increase the intelligence and randomness of the game play. Games with rich social interactions have proven successful in many of today’s massively multiplayer games.

Take advantage of mobile innovations:A huge amount of mobile technology research dollars have been spent on improving the usability and reliability of devices and networks. As a result, the mobile device hardware and network protocols are very different from the desktop/console world (e.g., Global Positioning System (GPS) extensions, barcode scanner, and Short Message Service (SMS)/Multimedia Message Service (MMS) messaging). Good mobile games should take advantage of those innovative device features and network infrastructures.

Nonexplicit content:Since all age/gender groups play mobile games and often in public/work settings, you should avoid explicit violent or sexual content.

Types of mobile games

Based on the above criteria, the most successful future mobile games are casual games that provide entertainment value to a broad range of players in all social settings. In particular, the following types of games are emerging as tomorrow’s killer games:

Multiplayer games:Those games could provide mobile access to established online game communities. Or, they could create completely different social structures taking advantage of mobile-specific features such as the multimedia messaging and location-based services. Good game design and management are crucial to this type of game’s success.

Content-based games:Those games deliver copyrighted multimedia entertainment content, such as celebrity photos, video clips, voice ringtones, and personalized sports games to music/movie/sports fans. The key to success is to provide a flow of high-quality content that justifies the subscription cost.

High-impact visual games:PC and console games have evolved from 2D to 3D. Mobile games will follow this trend too. There are already several mobile 3D toolkits and handsets available. However, 3D games are very resource intensive. They require expertise from both developers and graphic designers. Professional shops will most likely develop these games.

During mobile games’ early days, most developers were enthusiasts who wanted to play with their devices, learn new skills, and make a quick buck. However, as more developers enter this space, mobile games have evolved into major productions that involve professional designers, architects, developers, business dealers, lawyers, and artists. This is an inevitable trend as the industry matures. For developers, this change poses both challenges and opportunities. While it is harder to develop and sell simple games in one’s spare time, more pro shops will offer better employment opportunities for many people.

The mobile value chain

To fully understand the mobile game landscape, you must understand how the money flows. This business’s value chain is considerably different from traditional games or enterprise applications:

Developers:Software developers drive the value chain by creating great applications. However, most developers do not have the capacity to handle mass marketing. They also lack the distribution channels to reach consumers.

Publishers:Game publishers aggregate titles from developers. They build a brand name, certify the game for technical correctness, promote the game, and build business relationships with wireless carriers. Publishers also handle billing on the developer’s behalf and typically share revenue with the developer.

Wireless carriers:Wireless carriers are at the center of mobile game distribution channels. Carriers not only control the network but also own the customer information. It is up to them to decide what devices and services to support. Carriers take a big chunk of money out of the overall profit. Carriers can also bill the customers through existing service agreements.

Wireless device manufacturers:Device manufacturers drive the technical innovation. They make new hardware and support development platforms. In fact, J2ME’s success is largely due to major device manufacturer adoption. Device manufacturers represent an independent force between carriers and consumers.

Consumers:Consumers eventually pay for the costs and margins incurred for the providers along the chain. A consumer can purchase games from the publisher’s Website or through content provisioning systems provided by the carrier.

Figure 1 shows the value chain.

J2ME smart clients

The J2ME platform has emerged as the most prominent mobile gaming platform widely accepted by developers, device manufacturers, network carriers, and consumers. It has some very important features that benefit all parties.

Smart client characteristics

J2ME devices are smart. They can process information on their own. These are the most important characteristics differentiating J2ME smart phones from previous generations of mobile phones:

For users, a smart mobile phone’s most appealing feature is that you can play games without always-on network connections. Offline mode is necessary in today’s 2-2.5G networks where the coverage is sporadic and data traffic is expensive. The ability to cache data and queue network operations into transactions also significantly reduces the wireless network and improves application reliability.

Smart clients can integrate with backend game servers and peers (both wireless peers and Internet peers) using various protocols.

Smart clients support rich user interface (UI) features crucial for visually appealing games.

Smart clients can access mobile-specific network (e.g., SMS and MMS) or device extension (e.g., GPS) features. This makes it possible to develop games that take full advantage of the mobile lifestyle.

Smart clients offer stronger and more flexible security through advanced encryption and digital signature algorithms. With smart clients, it is possible to transport sensitive user privacy data over the Internet and build effective online societies.

A portable platform

Compared with other smart client platforms, J2ME has a unique advantage: it is designed for mobility. J2ME applications run on various devices from numerous vendors.

That is extremely important in the highly competitive mobile device business due to the large number of different devices. All major smart phone manufacturers have committed to support the J2ME platform. Code portability is crucial for developers who want to maintain a single codebase yet still reach the maximum number of consumers.

J2ME solves the “lowest common dominator” problem, which has plagued desktop Java before, by defining a multilayer architecture consisting of configurations, profiles, and optional packages. So far, in the mobile game industry, the most popular J2ME platform is Mobile Information Device Profile (MIDP) and the optional packages built on top of MIDP. In this article, I focus on the MIDP v2 platform.

Figure 2 shows the J2ME architecture.

Thanks to J2ME’s wide adoption, mobile Java developer support has grown into a sizable market. Almost all popular Java development tools have been adapted to fit J2ME developer needs. J2ME libraries and components are readily available from third-party providers. Many of those libraries provide similar features to their Java 2 Platform, Standard Edition (J2SE) counterparts. For example, the IBM Service Management Framework (SMF) supports Java servlets on PDAs; the PointBase Micro Edition provides a Java Database Connectivity (JDBC)-like access method for mobile relational databases; and the IAIK JCE-ME supports a lightweight version of Java Cryptography Extension (JCE). Those tools and libraries make it easy for J2SE developers to migrate their skills to the mobile world. In turn, that creates a large developer base for J2ME vendors to leverage. The positive feedback cycles will help J2ME’s growth.

A survey of APIs and tools

In this next section, I survey J2ME game-related APIs and examine the capabilities they provide for developers.

User interfaces

The MIDP runtime provides fine-grained controls over the mobile device’s screens and hardware keys. All MIDP UI classes inherit from the javax.microedition.Displayable interface:

The Screen class is the basis for the high-level UI widgets such as Alert, List, Form, and TextBox. The MIDP runtime controls how to display those high-level UI classes and how to assign action keys based on the specific device’s UI convention. The MIDP high-level UI widgets are best for textual controls. Among the high-level UI classes, the Form class is the most flexible. You can specify the layout of a Form screen and add items such as StringItem, TextField, DateField, ChoiceGroup, and Gauge.The MIDP v2 specification brings two important innovations to the high-level UI: First, it allows mixed text and image display on the same Form by introducing the Spacer and ImageItem items; second, it provides a mechanism for developers to design and implement their own item-level widgets through the CustomItem class. The developers have ultimate control over the CustomItem objects including pixel-level painting and internal event handling.

The Canvas class is the basis for the low-level MIDP UI. It provides access to pixel-level painting over the entire screen and custom mapping for all hardware keys.

You can just create a subclass of Canvas and override the paint() method for the display logic; the keyPressed(), keyRepeated(), and keyReleased() methods for key events; and the pointerPressed(), pointerDragged(), and pointerReleased() methods for pointer and touch screen pen events.

The GameCanvas class inherits from the Canvas class. It is part of the MIDP v2 game API and provides convenience mechanisms for game development. For example, in GameCanvas subclasses, you do not need to override the paint() method to draw the entire screen every time you make a change. You can get the Graphics object directly from the getGraphics() method and draw on it. When you need to update the display, you can call the flushGraphics() method. You can only update part of the screen using the flushGraphics() method. Compared with the Canvas class’s single paint() method approach, the GameCanvas enables us to easily maintain the graphic state and quickly update the animated part of the screen. Similarly, the GameCanvas class also provides a convenience method to poll key states through the getKeyStates() method as opposed to the callback methods in the Canvas class. That allows much more flexible execution flows in complex game screen classes.

Figure 3 displays the MIDP UI structure.

The MIDP v2 specification defines an entire API for gaming applications in the javax.microedition.lcdui.game package. Besides the GameCanvas class, it provides the Layer class that supports tiled or animated game background images. The game API also provides the Sprite class that handles animated figures as well as collisions.

They are essential components in 2D graphic games. On the 3D front, Java Specification Request (JSR) 184 tries to standardize the Java 3D API on mobile phones. It has made excellent progress. J2ME 3D tools for developers and artists are already available from SuperScape (see Resources). Large device manufacturers are moving quickly to support this new API on their high-end smart phone devices.

Figure 4 illustrates some of SuperScape’s Java 3D games.

In addition to the standard MIDP UI and game APIs, several other MIDP UI toolkits exist. They either provide functionalities specific to a device or aim to support a better high-level UI to ease game development:

The Nokia UI package provides controls for sound, light, and vibration components on Nokia mobile phones. The Nokia UI also supports true full-screen mode for more professional-looking games.

The Motorola Lightweight Widget Toolkit (LWT) is an independent windowing toolkit for Motorola phones.

The Nextel Open Windowing Toolkit (OWT) is an open source toolkit developed jointly by Motorola and Nextel. It sports a container model to control layouts and other UI components, which is familiar to desktop UI developers. The OWT is based on the Canvas class and runs on all MIDP phones. However, if you use the OWT library, you must include it in your distribution MIDlet suite.

The Synclast UI project develops an open source UI package that supports the container model. Based on the MIDP v1 Canvas class, it supports many MIDP v2 widgets. As a result, it can allow MIDP v2 applications to run on today’s MIDP v1 devices with little modification. As with the OWT, you must bundle the Synclast library in the distribution application.

Overall, the MIDP platform offers various choices for rich UI games.

Network and backend integration

As I previously mentioned, the future of mobile gaming is networked multiplayer games. Networking in J2ME is supported through the Generic Connection Framework (GCF).

At the core of GCF is a factory class javax.microedition.io.Connector. You can pass a protocol and address string to the static method Connector.open() to obtain a connection object to a remote host:

The HTTP protocol support is mandatory in MIDP. If you pass a http://hostname:port connection string to the Connector.open() method, a HttpConnection object will be returned. You can open input/output (I/O) data streams directly on the connection and write/receive data to/from the remote host.

The Unix sockets, User Datagram Protocol (UDP) connections, or direct TCP/IP connections are also supported in some implementations. However, you should note that mobile networks are fundamentally different from the wired Internet. Some networks simulate socket connections on top of the HTTP layer. So, the direct sockets do not necessarily yield in performance gains. I recommend HTTP for most occasions.

The J2ME Wireless Messaging API (WMA) supports SMS messaging between mobile handsets in the GCF. You can send SMS messages to another handset using a MessageConnection object obtained by the sms://phone_number:port connection string. You can also open a “server” connection that listens for incoming SMS messages using the sms://port string. Incoming SMS messages can be handled synchronously or asynchronously.

In MIDP v2, the “server” SMS connection can be registered with the push registry managed by the J2ME runtime. It allows the developer to invoke a message-processing MIDlet upon the arrival of a certain message.

Above the protocol level, J2ME supports several ways to pass structured application data:

The MIDP DataInputStream and DataOutputStream classes support Java’s convenience I/O methods (e.g., writeInt(), writeUTF(), writeFully(), etc. and the corresponding readXXX() methods) to (de)serialize common data values and objects. Using paired writeXXX() and readXXX() methods on both sides of the communication channel can greatly simplify the developers’ work and increase the robustness of end-to-end applications.

The MIDP platform supports several XML parsers if you need more structured data exchange. The XML parsers support the Simple API for XML (SAX), XmlPull, and lightweight Document Object Model (DOM) parsing paradigms. JSR 172 (J2ME Web Services Specification) is developing a standardized XML parser API for J2ME.

Simple Object Access Protocol (SOAP)-based Web services is the end-to-end integration scheme of the future. The J2ME platform is well positioned to support SOAP message exchanges through third-party toolkits such as kSOAP (see Resources) as well as standardized APIs such as JSR 172.

Data management

On-device data management is a core feature in smart client games. J2ME has strong support in this area:

The standard data persistence facility on MIDP is the Recordstore Management System (RMS). The RMS stores binary data (byte arrays) in linear records. It does not allow random access and does not support any hierarchical data structure. But it offers limited functionalities to search the storage and order the search results. The RMS is mandatory in all MIDP devices. It is sufficient for most purposes. However, the MIDP itself does not provide an API to synchronize RMS data with backend applications. JSR 230 (Data Sync API) has just started to develop such a synchronization API.

JSR 75 (PDA Optional Packages for J2ME) provides access to the device’s native Personal Information Management (PIM) applications (e.g., calendar, address book, email, and to-do list) and filesystem. The PIM data and files can be synchronized to desktop computers through the device’s native synchronization suite.

For more complex data, you can use mobile databases. Several commercial MIDP databases (both relational and object oriented) and synchronization engines are available on the MIDP platform (see “High-Availability Mobile Applications” (JavaWorld, June 2003)).

Multimedia

Multimedia playback functionalities are crucial in content-driven mobile entertainment applications. The J2ME Multimedia API (JSR 135) is J2ME’s standard framework for playing multimedia content. Through the Player interface, it plays multiple audio and video formats from a variety of data sources. The Multipurpose Internet Mail Extensions (MIME) types passed to the player at runtime specify the content format. Each device implementation of the Multimedia API supports a different set of MIME types depending on the hardware and native player capabilities. Currently, almost all Multimedia API-compatible devices support simple ringtone playbacks. Support for more sophisticated formats such as MP3 audio and 3GPP video or even MPEG4 video are just around the corner.

Security

Mobile games involve downloadable code, copyrighted content, and financial transactions. Security is crucial to protect the interests of the users, developers, publishers, and carriers. Security is especially important in multiplayer games where some users try to beat the system by exploiting security holes. J2ME offers excellent support for both application and communication security:

The MIDP v2 specification supports application signing using the developer or distributor’s digital certificates. Based on the signer’s identity (security domain), the runtime security manager can grant API-level access permissions to the application. For example, an application that comes from a less trusted source might not be allowed to make network connections or send SMS messages.

The MIDP v2 specification also mandates the support for HTTPS on all handsets. That provides the basis for secure information exchange over the Internet.

If the connection-based HTTPS is still not flexible enough for some applications, many third-party cryptography packages are available on the MIDP platform (see “Data Security in Mobile Java Applications” (JavaWorld, December 2002)). They allow the encryption or signing of arbitrary pieces of information.

JSR 177 (Security and Trust API for J2ME) is an effort to standardize access to hardware security elements (e.g., the Subscriber Identity Module (SIM) card) embedded in the device. For example, it could allow J2ME developers to retrieve the digital certificate stored on the SIM card or use hardware-accelerated encryption algorithms.

Provisioning and selling

Mobile game delivery to consumers is a complex process that involves many parties. The MIDP specification includes a section about over-the-air (OTA) provisioning. It describes how to download an MIDP game over the Wireless Application Protocol (WAP) network, and how the Java Application Management Software (AMS) should install the application and then make it available to the user. The OTA process provides a feedback mechanism for the client device to report the installation status back to a server. It offers the technical basis for the more complex commercial deployment process. In the commercial world, you should consider several important additional processes:

The application must be certified free of viruses and put into a carrier-supported catalog.

A different client device might be provided with a different jar file that makes maximum use of the device capability (graphics and installed optional packages).

Billing of the customer and payments to the developer must be seamlessly handled. The one-click payment system directly from the phone is critically important.

Several commercial provisioning solutions are already available for carriers and publishers. JSR 124 (Java 2 Platform, Enterprise Edition (J2EE) Client Provisioning Specification) tries to standardize those solutions by defining a generic J2EE framework for client deployment. Plug-ins for different OTA specifications, customer tracking schemes, and billing services can be developed and designed to work together in the framework. Such efforts are crucial to J2ME games’ commercial success.

Figure 5 shows the J2EE Client Provisioning Specification architecture.

In this article, I explained why multiplayer mobile games with casual contents are the future of the gaming industry. Mobile device manufacturers have seen this tremendous opportunity and have already pushed out devices specifically designed for mobile gaming (e.g., Nokia N-Gage). J2ME/MIDP has emerged as one of the most important technology platforms for those mobile gaming devices and smart phones. After reading this article, you should understand J2ME’s strengths and weaknesses in mobile gaming. I also introduced you to the key game-related innovations in MIDP v2 and its optional packages.

About the author

Michael Yuan is the author of Enterprise J2ME. He writes and speaks frequently on the topics of J2ME, J2EE, and mobile enterprise applications. Currently, he leads an effort to build a series of blueprint applications for the Nokia Developer Platforms. (source: javaworl


上一篇:

下一篇: