making cell phone games an overview ray ratelis guild software, inc
Post on 15-Jan-2016
214 views
TRANSCRIPT
Making Cell Phone Making Cell Phone GamesGamesAn OverviewAn Overview
Ray RatelisRay RatelisGuild Software, Inc.Guild Software, Inc.
PlatformsPlatforms
BREWBREW
iPhoneiPhone
J2MEJ2ME
Java 2 Micro EditionJava 2 Micro Edition
ConfigurationConfiguration CLDC-1.0 (JSR30)CLDC-1.0 (JSR30) CLDC-1.1 (JSR139)CLDC-1.1 (JSR139)
ProfileProfile MIDP-1.0 (JSR37)MIDP-1.0 (JSR37) MIDP-2.0 (JSR118)MIDP-2.0 (JSR118)
JSR?JSR?
JSR is Java Specification Request. It is JSR is Java Specification Request. It is similar to RFC in the internet world.similar to RFC in the internet world.
http://jcp.org/en/jsrhttp://jcp.org/en/jsr
Connected Limited Device Connected Limited Device ConfigurationConfiguration
Defines a base set of APIs and VM Defines a base set of APIs and VM features that are required for the J2ME features that are required for the J2ME runtime.runtime.
Slightly limited subset of J2SE APIs. Some Slightly limited subset of J2SE APIs. Some Java features such as reflection are limited Java features such as reflection are limited or not present.or not present.
CLDC 1.0CLDC 1.0
No floating pointNo floating point
No weak referencesNo weak references
Minimum total memory requirement of Minimum total memory requirement of 160k160k
CLDC 1.1CLDC 1.1
Added floating point support and weak Added floating point support and weak referencesreferences
Minimum total memory requirement raised Minimum total memory requirement raised to 192kto 192k
Mobile Information Device ProfileMobile Information Device Profile
Defines an additional set of APIs that Defines an additional set of APIs that support a narrower category of devicessupport a narrower category of devices Networking APIs (http, https, sockets)Networking APIs (http, https, sockets) Lcdui API (Canvas, input events, rendering, Lcdui API (Canvas, input events, rendering,
images [png, jpg])images [png, jpg]) Game API (sprites, layers, tile grids, sprite Game API (sprites, layers, tile grids, sprite
collision detection)collision detection) Media API (wav, au, mp3, midi, tone Media API (wav, au, mp3, midi, tone
sequences)sequences)
MIDP 2.0 vs. 1.0MIDP 2.0 vs. 1.0
Game APIGame API
Media APIMedia API
Authentication APIAuthentication API
Optional PackagesOptional Packages
Bluetooth APIBluetooth API
SMS and SMM messaging APISMS and SMM messaging API
OthersOthers
No guarantee they exist. I don’t yet know No guarantee they exist. I don’t yet know what happens when a MIDlet tries to use what happens when a MIDlet tries to use an API that doesn’t exist on the device.an API that doesn’t exist on the device.
MIDletsMIDlets
Applications written using the MIDP profile Applications written using the MIDP profile are called MIDlets.are called MIDlets.
Defacto standard for downloadable cell Defacto standard for downloadable cell phone games written in Java.phone games written in Java.
SDKsSDKs
Java ME SDK 3.0Java ME SDK 3.0 Sample appsSample apps IDEIDE EmulatorEmulator
Java SE Dev Kit 1.6 or higherJava SE Dev Kit 1.6 or higher Java Runtime EnvironmentJava Runtime Environment
Java ME API DocumentationJava ME API Documentation http://java.sun.com/javame/reference/apis/jsr118/http://java.sun.com/javame/reference/apis/jsr118/
Available on Sun’s websiteAvailable on Sun’s website
InstallationInstallation
First install Java SE Dev KitFirst install Java SE Dev KitThen install Java ME SDKThen install Java ME SDKRun the SDK IDERun the SDK IDEAdd new Java PlatformAdd new Java Platform Tools -> Java Platform -> Add Platform…Tools -> Java Platform -> Add Platform… Select Java ME MIDP Platform EmulatorSelect Java ME MIDP Platform Emulator Then choose the Java ME Platform SDK that Then choose the Java ME Platform SDK that
was just installed. I think this sets up the was just installed. I think this sets up the emulator.emulator.
ProgrammingProgramming
Main application must subclass the MIDlet Main application must subclass the MIDlet class.class. public class HelloMIDlet extends MIDletpublic class HelloMIDlet extends MIDlet Implement startApp(), pauseApp(), Implement startApp(), pauseApp(),
destroyApp()destroyApp() Usually creates a canvas and game thread Usually creates a canvas and game thread
and listens for commandsand listens for commands
ProgrammingProgramming
Create a canvasCreate a canvas Subclass either Canvas or GameCanvas Subclass either Canvas or GameCanvas
classclass public class TheCanvas extends public class TheCanvas extends
GameCanvasGameCanvas Implement paint(), keyPressed(), Implement paint(), keyPressed(),
keyReleased()keyReleased() Must be set as the active canvas to the MIDlet Must be set as the active canvas to the MIDlet
displaydisplayDisplay.getDisplay(midlet).setCurrent(canvas)Display.getDisplay(midlet).setCurrent(canvas)
ProgrammingProgramming
Create a game threadCreate a game thread public class GameThread implements public class GameThread implements
RunnableRunnable Implement run()Implement run() This is where the main game loop can resideThis is where the main game loop can reside
Input()Input()
Process()Process()
Render()Render()
Sleep()Sleep()
ProgrammingProgramming
Optionally create a command listenerOptionally create a command listener public class cmdListener implements public class cmdListener implements
CommandListenerCommandListener Used to receive command eventsUsed to receive command events Commands are created and added to the Commands are created and added to the
CanvasCanvas CommandListener is added to the CanvasCommandListener is added to the Canvas
canvasobject.setCommandListener(cmdlistenerobjcanvasobject.setCommandListener(cmdlistenerobject)ect)
ProgrammingProgramming
Commands show up as the menu along Commands show up as the menu along the bottom of the displaythe bottom of the display exitCommand = new Command(“Exit”, exitCommand = new Command(“Exit”,
Command.EXIT, 0)Command.EXIT, 0) canvasobject.addCommand(exitCommand)canvasobject.addCommand(exitCommand)
RunRun
The J2ME SDK comes with an emulator The J2ME SDK comes with an emulator that emulates a series of different mobile that emulates a series of different mobile devicesdevices Touch phonesTouch phones Clamshell phonesClamshell phones
Much faster than an actual phoneMuch faster than an actual phone
DistributionDistribution
.JAR .JAR Java ARchiveJava ARchive Main app file, contains all code and resourcesMain app file, contains all code and resources
.JAD.JAD Java Application DescriptorJava Application Descriptor Describes what configuration and profile Describes what configuration and profile
needs to be supported by the device, the needs to be supported by the device, the name and icon to show in the App menu, name and icon to show in the App menu, vendor, version, path to .JAR, size of .JARvendor, version, path to .JAR, size of .JAR
DistributionDistribution
Put both files onto a web sitePut both files onto a web site .JAR.JAR
mime type: application/java-archivemime type: application/java-archive .JAD.JAD
mime type: text/vnd.sun.j2me.app-descriptormime type: text/vnd.sun.j2me.app-descriptor
Browse to the .JAD file using the cell Browse to the .JAD file using the cell phone’s browser and it will ask if you want phone’s browser and it will ask if you want to install itto install it
DistributionDistribution
If available, use cell phone maker’s App If available, use cell phone maker’s App Installer to install over USB or BluetoothInstaller to install over USB or Bluetooth Not every phone has this capability (mine Not every phone has this capability (mine
doesn’t as far as I can find)doesn’t as far as I can find)
Email or otherwise send the files to your Email or otherwise send the files to your cell phone (I have no idea if this works)cell phone (I have no idea if this works)
Questions?Questions?Comments?Comments?