Download Making Cell Phone Games

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Making Cell Phone
Games
An Overview
Ray Ratelis
Guild Software, Inc.
Platforms
BREW
iPhone
J2ME
Java 2 Micro Edition
Configuration


CLDC-1.0 (JSR30)
CLDC-1.1 (JSR139)
Profile


MIDP-1.0 (JSR37)
MIDP-2.0 (JSR118)
JSR?
JSR is Java Specification Request. It is
similar to RFC in the internet world.
http://jcp.org/en/jsr
Connected Limited Device
Configuration
Defines a base set of APIs and VM
features that are required for the J2ME
runtime.
Slightly limited subset of J2SE APIs. Some
Java features such as reflection are limited
or not present.
CLDC 1.0
No floating point
No weak references
Minimum total memory requirement of
160k
CLDC 1.1
Added floating point support and weak
references
Minimum total memory requirement raised
to 192k
Mobile Information Device Profile
Defines an additional set of APIs that
support a narrower category of devices




Networking APIs (http, https, sockets)
Lcdui API (Canvas, input events, rendering,
images [png, jpg])
Game API (sprites, layers, tile grids, sprite
collision detection)
Media API (wav, au, mp3, midi, tone
sequences)
MIDP 2.0 vs. 1.0
Game API
Media API
Authentication API
Optional Packages
Bluetooth API
SMS and SMM messaging API
Others
No guarantee they exist. I don’t yet know
what happens when a MIDlet tries to use
an API that doesn’t exist on the device.
MIDlets
Applications written using the MIDP profile
are called MIDlets.
Defacto standard for downloadable cell
phone games written in Java.
SDKs
Java ME SDK 3.0



Sample apps
IDE
Emulator
Java SE Dev Kit 1.6 or higher

Java Runtime Environment
Java ME API Documentation

http://java.sun.com/javame/reference/apis/jsr118/
Available on Sun’s website
Installation
First install Java SE Dev Kit
Then install Java ME SDK
Run the SDK IDE
Add new Java Platform



Tools -> Java Platform -> Add Platform…
Select Java ME MIDP Platform Emulator
Then choose the Java ME Platform SDK that
was just installed. I think this sets up the
emulator.
Programming
Main application must subclass the MIDlet
class.



public class HelloMIDlet extends MIDlet
Implement startApp(), pauseApp(),
destroyApp()
Usually creates a canvas and game thread
and listens for commands
Programming
Create a canvas




Subclass either Canvas or GameCanvas
class
public class TheCanvas extends
GameCanvas
Implement paint(), keyPressed(),
keyReleased()
Must be set as the active canvas to the MIDlet
display
Display.getDisplay(midlet).setCurrent(canvas)
Programming
Create a game thread



public class GameThread implements
Runnable
Implement run()
This is where the main game loop can reside
Input()
Process()
Render()
Sleep()
Programming
Optionally create a command listener




public class cmdListener implements
CommandListener
Used to receive command events
Commands are created and added to the
Canvas
CommandListener is added to the Canvas
canvasobject.setCommandListener(cmdlistenerobj
ect)
Programming
Commands show up as the menu along
the bottom of the display


exitCommand = new Command(“Exit”,
Command.EXIT, 0)
canvasobject.addCommand(exitCommand)
Run
The J2ME SDK comes with an emulator
that emulates a series of different mobile
devices


Touch phones
Clamshell phones
Much faster than an actual phone
Distribution
.JAR


Java ARchive
Main app file, contains all code and resources
.JAD


Java Application Descriptor
Describes what configuration and profile
needs to be supported by the device, the
name and icon to show in the App menu,
vendor, version, path to .JAR, size of .JAR
Distribution
Put both files onto a web site

.JAR
mime type: application/java-archive

.JAD
mime type: text/vnd.sun.j2me.app-descriptor
Browse to the .JAD file using the cell
phone’s browser and it will ask if you want
to install it
Distribution
If available, use cell phone maker’s App
Installer to install over USB or Bluetooth

Not every phone has this capability (mine
doesn’t as far as I can find)
Email or otherwise send the files to your
cell phone (I have no idea if this works)
Questions?
Comments?