Showing posts with label J2ME. Show all posts
Showing posts with label J2ME. Show all posts

Saturday, June 18, 2011

Game Animation with Java MIDP






Contents
1 Introduction..........................................................................................................................................................5
1.1 Purpose and Scope................................................................................................................................5
1.2 Target Audience.....................................................................................................................................5
2 Sprite Graphics.....................................................................................................................................................6
2.1 Introduction to Sprites.........................................................................................................................6
2.2 Sprite Properties ....................................................................................................................................6
2.3 Frames ......................................................................................................................................................6
2.4 Threading.................................................................................................................................................8
2.4.1 Extending the Thread Object............................................................................................8
2.4.2 Implementing the Runnable Interface .........................................................................9
2.4.3 Using Timers ...................................................................................................................... 10
2.5 Tiled Backgrounds.............................................................................................................................. 11
2.6 Double Buffering and Clipping........................................................................................................ 15
2.6.1 Double Buffering............................................................................................................... 15
2.6.2 Clipping................................................................................................................................ 15
3 An Example: Helicopter.................................................................................................................................. 17
3.1 Overview ............................................................................................................................................... 17
3.2 ExampleMidlet.java ............................................................................................................................ 18
3.3 MyCanvas.java...................................................................................................................................... 20
3.4 MyMovingObject.java......................................................................................................................... 23
3.5 MyBackground.java............................................................................................................................ 25
3.6 Helicopter.jad....................................................................................................................................... 30


Another Game Programming Books
Another J2ME Books
Download

Sunday, January 16, 2011

Developing Wireless Applications








Agenda
J2ME Platform Overview
MIDP 2.0 Technical Overview
MIDP Development and Deployment
J2ME Wireless Toolkit 2.0 (WTK)
MIDP 2.0 APIs
Wireless Messaging APIs (WMA) and
Mobile Media APIs (MMA)
MIDP 2.0 Programming Practices
Summary and Resources


Another J2ME Books
Another Smart Phone Books
Download

Wednesday, January 12, 2011

Core J2ME Technology & MIDP






Table of Content
Table of Content ........................................................................................................................ i
Copyright................................................................................................................................. vii
Dedication .......................................................................................................................... viii
Preface................................................................................................................................... viii
Who Is This Book For....................................................................................................... viii
Focus of this Book .............................................................................................................. ix
Contents ............................................................................................................................... ix
Acknowledgments ................................................................................................................. xiii
About the Author.................................................................................................................... xiii
Chapter 1. THE BASICS Of J2ME......................................................................................... 1
Java Editions........................................................................................................................ 1
Why J2ME?.......................................................................................................................... 2
Configurations...................................................................................................................... 3
Profiles.................................................................................................................................. 3
Java Virtual Machines ......................................................................................................... 4
Big Picture View of the Architecture.................................................................................. 5
Compatibility between Java Editions ................................................................................ 6
Putting all the Pieces Together.......................................................................................... 7
Chapter 2. CONNECTED, LIMITED DEVICE CONFIGURATION (CLDC)..................... 8
Hardware Requirements..................................................................................................... 9
Software Requirements....................................................................................................... 9
The Java Virtual Machine Specification............................................................................ 9
Handling Security............................................................................................................... 11
Class File Verification........................................................................................................ 12
J2SE Inherited Classes..................................................................................................... 12
CLDC Specific Classes ..................................................................................................... 16
K Virtual Machine ............................................................................................................... 17
Chapter 3. MOBILE INFORMATION DEVICE PROFILE (MIDP)................................... 18
Hardware and Software Requirements .......................................................................... 18
MID Profile Architecture .................................................................................................... 19
The MIDlet Suite................................................................................................................. 20
Accessing JAR/JAD Attributes from a MIDlet................................................................ 24
Chapter 4. DEVELOPMENT ENVIORNMENT .................................................................. 27
Download the Software..................................................................................................... 27
Install the Software ............................................................................................................ 28
Command Line Development........................................................................................... 33
Packaging a MIDlet............................................................................................................ 36
Running a MIDlet on an Emulator ................................................................................... 39
Download MIDlet onto a Mobile Device.......................................................................... 41
Project Management Using Java Packages.................................................................. 41
J2ME Wireless Toolkit....................................................................................................... 45
Download ............................................................................................................................ 46
Installation ........................................................................................................................... 46
Create a New Project ........................................................................................................ 47
Configure the Project Settings ......................................................................................... 48
Write the Code and Build the Project.............................................................................. 51
Using Java Packages........................................................................................................ 53
Locating the JAR and JAD Files...................................................................................... 54
Configuring the Emulator .................................................................................................. 55
Toolkit Summary ................................................................................................................ 56
Chapter 5. BASICS OF MIDLETS AND THE DISPLAY................................................... 57
MIDlet.................................................................................................................................. 57
MIDletStateChangeException.......................................................................................... 61
Display ................................................................................................................................ 66
Displayable......................................................................................................................... 69
Chapter 6. EVENT HANDLING............................................................................................ 72
The Big Picture................................................................................................................... 72
Command Objects ............................................................................................................. 73
Item Objects........................................................................................................................ 74
Command and CommandListener .................................................................................. 75
Item and ItemStateListener .............................................................................................. 87
Chapter 7. HIGH-LEVEL USER INTERFACE: PART I .................................................... 91
Screen................................................................................................................................. 91
Form.................................................................................................................................... 93
Item ..................................................................................................................................... 94
DateField ............................................................................................................................. 98
Gauge ............................................................................................................................... 104
StringItem......................................................................................................................... 109
TextField........................................................................................................................... 115
Choice and ChoiceGroup ............................................................................................... 123
Image and ImageItem ..................................................................................................... 132
Chapter 8. HIGH-LEVEL USER INTERFACE: PART II ................................................. 146
List ..................................................................................................................................... 147
TextBox............................................................................................................................. 157
Alert and AlertType.......................................................................................................... 172
Ticker ................................................................................................................................ 180
Chapter 9. LOW-LEVEL USER INTERFACE.................................................................. 184
Canvas.............................................................................................................................. 184
Graphics ............................................................................................................................ 209
Chapter 10. CREATING A DISPLAYER MANAGER...................................................... 253
Animation MIDlet.............................................................................................................. 254
Display Manager API....................................................................................................... 257
Animating a Series of Images ........................................................................................ 260
Source Code..................................................................................................................... 262
Chapter 11. RECORD MANAGEMENT SYSTEM (RMS).............................................. 271
Persistent Storage Through the Record Store ............................................................ 271
Navigating with RecordEnumeration............................................................................. 284
Sorting with RecordComparator .................................................................................... 286
Searching with RecordFilter ........................................................................................... 303
Notification of Changes with RecordListener............................................................... 316
Exception Handling.......................................................................................................... 320
Chapter 12. TODO LIST EXAMPLE: PART I................................................................... 322
Using the Todo List.......................................................................................................... 322
Interface Design ............................................................................................................... 325
Data Design ...................................................................................................................... 326
Application Logic .............................................................................................................. 331
Source Code..................................................................................................................... 333
Chapter 13. SCHEDULING TASKS .................................................................................. 350
Timer ................................................................................................................................. 350
TimerTask ......................................................................................................................... 353
Example: Timer Template............................................................................................... 354
Example: Todo List MIDlet Part II—Delay Timer ........................................................ 358
Example: Animation with Timer/TimerTask ................................................................. 361
Chapter 14. GENERIC CONNECTION FRAMEWORK................................................. 369
Connection Hierarchy...................................................................................................... 369
HTTP Connection............................................................................................................. 371
Chapter 15. MIDP FOR THE PALM OS ........................................................................... 440
Device Requirements ...................................................................................................... 441
Download .......................................................................................................................... 442
Installation ......................................................................................................................... 442
MIDlets.............................................................................................................................. 444
Configuring Preferences ................................................................................................. 450
Example: keyCodes and gameActions......................................................................... 455
Appendix A. Over the Air User Initiated Provisioning Recommended Practice.......... 468
General Information......................................................................................................... 468
Device (Client) .................................................................................................................. 469
MIDlet Suite Upgrade ...................................................................................................... 473
MIDlet Suite Removal...................................................................................................... 473
Server ............................................................................................................................... 473
WAP.................................................................................................................................. 475
Appendix B. CLDC API........................................................................................................ 477
java.io................................................................................................................................ 480
ByteArrayInputStream..................................................................................................... 480
ByteArrayOutputStream.................................................................................................. 481
DataInput.......................................................................................................................... 481
DataInputStream.............................................................................................................. 482
DataOutput....................................................................................................................... 483
DataOutputStream........................................................................................................... 484
EOFException................................................................................................................... 484
InputStream...................................................................................................................... 485
InputStreamReader ......................................................................................................... 485
InterruptedIOException ................................................................................................... 486
IOException...................................................................................................................... 486
OutputStream ................................................................................................................... 486
OutputStreamWriter......................................................................................................... 487
PrintStream...................................................................................................................... 487
Reader ............................................................................................................................... 488
UnsupportedEncodingException ................................................................................... 489
UTFDataFormatException.............................................................................................. 489
Writer................................................................................................................................. 490
java.lang ............................................................................................................................ 490
ArithmeticException ......................................................................................................... 491
ArrayIndexOutOfBoundsException ............................................................................... 491
ArrayStoreException........................................................................................................ 491
Boolean............................................................................................................................. 492
Byte ................................................................................................................................... 492
Character.......................................................................................................................... 493
Class ................................................................................................................................. 494
ClassCastException......................................................................................................... 494
ClassNotFoundException ............................................................................................... 494
Error .................................................................................................................................. 495
Exception.......................................................................................................................... 495
IllegalAccessException ................................................................................................... 495
IllegalArgumentException ............................................................................................... 496
IllegalMonitorStateException.......................................................................................... 496
IllegalThreadStateException .......................................................................................... 496
IndexOutOfBoundsException......................................................................................... 496
InstantiationException ..................................................................................................... 497
Integer............................................................................................................................... 497
InterruptedException ....................................................................................................... 498
Long .................................................................................................................................. 498
Math .................................................................................................................................. 499
NegativeArraySizeException.......................................................................................... 499
NullPointerException ....................................................................................................... 500
NumberFormatException................................................................................................ 500
Object................................................................................................................................ 500
OutOfMemoryError .......................................................................................................... 501
Runnable ........................................................................................................................... 501
Runtime ............................................................................................................................. 501
RuntimeException............................................................................................................ 502
SecurityException ............................................................................................................ 502
Short.................................................................................................................................. 502
String................................................................................................................................. 503
StringBuffer ....................................................................................................................... 505
StringIndexOutOfBoundsException .............................................................................. 506
System.............................................................................................................................. 506
Thread............................................................................................................................... 507
Throwable......................................................................................................................... 508
VirtualMachineError......................................................................................................... 508
java.util.............................................................................................................................. 509
Calendar ............................................................................................................................ 509
Date................................................................................................................................... 511
EmptyStackException ..................................................................................................... 511
Enumeration..................................................................................................................... 511
Hashtable .......................................................................................................................... 512
NoSuchElementException.............................................................................................. 512
Random............................................................................................................................ 513
Stack ................................................................................................................................. 513
TimeZone .......................................................................................................................... 514
Vector................................................................................................................................ 514
javax.microedition.io ........................................................................................................ 515
Connection....................................................................................................................... 516
ConnectionNotFoundException ..................................................................................... 516
Connector......................................................................................................................... 516
ContentConnection.......................................................................................................... 517
Datagram.......................................................................................................................... 517
DatagramConnection....................................................................................................... 518
InputConnection ............................................................................................................... 518
OutputConnection............................................................................................................ 519
StreamConnection ........................................................................................................... 519
StreamConnectionNotifier............................................................................................... 519
Appendix C. MIDP API ........................................................................................................ 520
Alert: javax.microedition.lcdui.Alert ............................................................................... 522
AlertType: javax.microedition.lcdui.AlertType.............................................................. 522
Canvas: javax.microedition.lcdui.Canvas..................................................................... 523
Choice: javax.microedition.lcdui.Choice....................................................................... 524
ChoiceGroup: javax.microedition.lcdui.ChoiceGroup................................................. 524
Command: javax.microedition.lcdui.Command........................................................... 525
CommandListener: javax.microedition.lcdui.CommandListener............................... 526
DateField: javax.microedition.lcdui.DateField.............................................................. 526
Display: javax.microedition.lcdui.Display...................................................................... 527
Displayable: javax.microedition.lcdui.Displayable ...................................................... 527
Font: javax.microedition.lcdui.Font................................................................................ 528
Form: javax.microedition.lcdui.Form............................................................................. 528
Gauge: javax.microedition.lcdui.Gauge........................................................................ 529
Graphics: javax.microedition.lcdui.Graphics................................................................ 529
HttpConnection: javax.microedition.io.HttpConnection.............................................. 531
Image: javax.microedition.lcdui.Image.......................................................................... 536
ImageItem: javax.microedition.lcdui.ImageItem.......................................................... 536
Item: javax.microedition.lcdui.Item................................................................................ 537
ItemStateListener: javax.microedition.lcdui.ItemStateListener ................................. 537
List: javax.microedition.lcdui.List ................................................................................... 538
MIDlet: javax.microedition.midlet.MIDlet ...................................................................... 539
MIDletStateChangeException:
javax.microedition.midlet.MIDletStateChangeException ........................................... 539
RecordComparator: javax.microedition.rms.RecordComparator ............................. 539
RecordEnumeration: javax.microedition.rms.RecordEnumeration .......................... 540
RecordFilter: javax.microedition.rms.RecordFilter...................................................... 540
RecordListener: javax.microedition.rms.RecordListener ........................................... 541
RecordStore: javax.microedition.rms.RecordStore..................................................... 541
Record Store Exceptions ................................................................................................ 542
Screen: javax.microedition.lcdui.Screen ...................................................................... 543
StringItem: javax.microedition.lcdui.StringItem ........................................................... 543
TextBox: javax.microedition.lcdui.TextBox ...................................................................... 543
TextField: javax.microedition.lcdui.TextField............................................................... 544
Ticker: javax.microedition.lcdui.Ticker .......................................................................... 545
Timer: java.util.Timer....................................................................................................... 546
TimerTask: java.util.TimerTask...................................................................................... 546

Another J2ME Books
Another Programming Language Books
Download

Thursday, October 14, 2010

Wireless Java Developing with J2ME, Second Edition












by Jonathan Knudsen ISBN:1590590775
Apress © 2003 (384 pages)

This edition is updated to include coverage of the next version of programs for mobile Java devices. MIDP 2.0 contains many exciting new features, such as sound HTTPS support, lots of user interface API enhancements, a Game API, and much more.
Table of Contents
Wireless Java Developing with J2ME, Second Edition
Preface
Chapter 1 - Introduction
Chapter 2 - Building MIDlets
Chapter 3 - All About MIDlets
Chapter 4 - Almost the Same Old Stuff
Chapter 5 - Creating a User Interface
Chapter 6 - Lists and Forms
Chapter 7 - Custom Items
Chapter 8 - Persistent Storage
Chapter 9 - Connecting to the World
Chapter 10 - Programming a Custom User Interface
Chapter 11 - The Game API
Chapter 12 - Sound and Music
Chapter 13 - Performance Tuning
Chapter 14 - Parsing XML
Chapter 15 - Protecting Network Data
Appendix A - MIDP API Reference
Index
List of Figures
List of Tables
List of Listings
List of Sidebars

Download
Another J2ME Book
Another Wireles Network Books
Another Smartphone Books

Friday, September 24, 2010

Cracking the Code Wireless Programming with J2ME












Contents
Preface.........................................................................................................viii
Chapter 1: An Overview of J2ME .................................................................1
Introduction ............................................................................................................................................ 1
What J2ME is about......................................................................................................................... 1
What J2ME offers........................................................................................................................... 2
J2ME Virtual Machines .......................................................................................................................... 3
The K Virtual Machine (KVM) ...................................................................................................... 3
The C Virtual Machine (CVM)....................................................................................................... 4
Configurations ........................................................................................................................................ 5
CLDC.............................................................................................................................................. 5
CDC................................................................................................................................................. 7
Profiles.................................................................................................................................................... 8
Mobile Information Device Profile (MIDP)................................................................................... 8
Foundation Profile ........................................................................................................................... 9
Other profiles .................................................................................................................................. 9
Getting Set to Program with J2ME....................................................................................................... 10
Our First J2ME Application.................................................................................................................. 10
RelatedJava Technologies.................................................................................................................... 12
PersonalJava.................................................................................................................................. 12
Java Card....................................................................................................................................... 13
Summary............................................................................................................................................... 15
Chapter 2: Programming Techniques for J2ME........................................16
Constraints of J2ME Targeted Devices................................................................................................ 16
Limited processor speed ................................................................................................................ 16
Limited memory and storage......................................................................................................... 17
Limited networking and bandwidth .............................................................................................. 17
Wide variety of input/output methods .......................................................................................... 18
Size, shape, and weight.................................................................................................................. 20
Rapid changes in the world of small devices................................................................................ 21
Operating systems for mobile devices .......................................................................................... 21
Programming Techniques to Counter the Limitations......................................................................... 22
Do not overload the processor....................................................................................................... 22
Conserve memory to the maximum extent ................................................................................... 22
Pass the load to the server ............................................................................................................. 24
Avoid using string concatenation.................................................................................................. 24
Give the garbage collector light work........................................................................................... 24
Use exceptions sparingly............................................................................................................... 24
Use local variables ......................................................................................................................... 24
Make your suite light..................................................................................................................... 24
Managing with the limited features of J2ME....................................................................................... 25
Plan your application well ............................................................................................................. 25
Use GUI classes optimally and creatively.....................................................................................25
Use the server’s functionality ........................................................................................................25
Use low-level UI APIs in MIDP....................................................................................................25
Use SyncML for data synchronization ..........................................................................................26
Summary ...............................................................................................................................................26
..................................27
Core Packages.......................................................................................................................................27
java.lang package ...........................................................................................................................27
java.io package ...............................................................................................................................27
java.util package .............................................................................................................................28
Brief introduction to commonly used packages............................................................................28
Generic Connection Framework ...........................................................................................................31
Kjava API..............................................................................................................................................33
Brief introduction to commonly used classes .......................................................................................36
Spotlet ............................................................................................................................................36
Graphics.........................................................................................................................................37
Button.............................................................................................................................................37
TextField........................................................................................................................................38
RadioButton and RadioGroup........................................................................................................38
HelpDisplay ...................................................................................................................................39
ScrollTextBox................................................................................................................................39
Database.........................................................................................................................................40
TextBox .........................................................................................................................................41
Installation of CLDC .............................................................................................................................41
Compiling, preverifying, and running applications ......................................................................42
Case Studies ..........................................................................................................................................43
TextField_Spotlet ...........................................................................................................................43
ScrollTextBox_Spotlet...................................................................................................................45
HelpDisplay_Spotlet ......................................................................................................................47
CheckRadio_Spotlet.......................................................................................................................49
HttpCheck_Spotlet .........................................................................................................................52
Server .............................................................................................................................................55
Socket_Check ................................................................................................................................55
Summary ...............................................................................................................................................62
Chapter 4: MIDP-MIDlet Implementation with Case Studies....................63
MIDlets and MIDlet States....................................................................................................................63
MIDlet Suites ........................................................................................................................................64
MIDP API .............................................................................................................................................64
Application Lifecycle Package..............................................................................................................65
User Interface Package ..........................................................................................................................66
Interface CommandListener...........................................................................................................67
Alert Class .....................................................................................................................................68
ChoiceGroup Class.........................................................................................................................69
Command Class.............................................................................................................................70
Display Class .................................................................................................................................71
Form Class.....................................................................................................................................71
Gauge Class ...................................................................................................................................72
Graphics Class ............................................................................................................................... 73
Class List....................................................................................................................................... 75
Class StringItem............................................................................................................................ 76
Class TextField .............................................................................................................................. 76
Class TextBox............................................................................................................................... 77
Class Ticker................................................................................................................................... 78
Persistence Package.............................................................................................................................. 78
Class RecordStore......................................................................................................................... 79
Exceptions in Persistance Package................................................................................................ 82
Installation of MIDP and Running Applications ................................................................................. 82
run.bat............................................................................................................................................ 83
sample.bat...................................................................................................................................... 84
example.jad ................................................................................................................................... 85
J2ME Wireless Toolkit ......................................................................................................................... 85
MIDP for Palm ..................................................................................................................................... 86
Case Studies.......................................................................................................................................... 91
TextFieldCheck............................................................................................................................. 91
LabelUI ......................................................................................................................................... 93
ChoiceGroupUI............................................................................................................................. 95
TickerUI ........................................................................................................................................ 98
MenuCheck ................................................................................................................................... 99
AddressBook............................................................................................................................... 101
TestHTTP.................................................................................................................................... 109
Summary............................................................................................................................................. 111
Chapter 5: Handling and Parsing XML in J2ME ......................................112
Brief Overview of XML ..................................................................................................................... 112
Structure of XML......................................................................................................................... 112
XML Schema.............................................................................................................................. 114
XML Parsing ...................................................................................................................................... 114
XML parsers available for KVM ................................................................................................ 115
Working with kXML........................................................................................................................... 115
org.kxml parser package ............................................................................................................. 116
org.kxml.io package..................................................................................................................... 117
Application ......................................................................................................................................... 117
Structure of the application ......................................................................................................... 117
Functioning of the application..................................................................................................... 117
Application description................................................................................................................ 117
Summary............................................................................................................................................. 124
Chapter 6: Project 1: Online Testing Engine...........................................125
User Interface ..................................................................................................................................... 125
Running the Project............................................................................................................................ 126
How It Works ..................................................................................................................................... 126
TestManager flow chart............................................................................................................... 132
TestManager.java ............................................................................................................................... 134
MainScreen.java................................................................................................................................. 139
QuestionParser.java............................................................................................................................ 155
Books.asp............................................................................................................................................ 159
TestFile.asp .........................................................................................................................................161
Summary .............................................................................................................................................163
Chapter 7: Project 2: Online Ordering System........................................164
User Interface......................................................................................................................................164
Running the Application.....................................................................................................................164
How It Works......................................................................................................................................165
Summary .............................................................................................................................................184
Chapter 8: Project 3: MP3 Player for Pocket PC .....................................185
Working with the CDC Specification .................................................................................................185
Using Emulated Environments............................................................................................................186
The PersonalJava Emulation Environment .................................................................................186
The Pocket PC emulation environment.......................................................................................188
Working without emulation .........................................................................................................189
JavaCheck ...........................................................................................................................................189
Introducing the project........................................................................................................................193
How It Works......................................................................................................................................193
How to Run .........................................................................................................................................200
Working With Wireless Networks ......................................................................................................201
Summary .............................................................................................................................................218
Chapter 9: Project 4 : Peer-to-Peer Search Application.........................219
User Interface......................................................................................................................................219
How It Works......................................................................................................................................220
Source Code ........................................................................................................................................226
Summary .............................................................................................................................................274
Chapter 10: Project 5: Mobile Web Services...........................................275
User Interface......................................................................................................................................275
How to Run .........................................................................................................................................278
How It Works......................................................................................................................................278
MainClass.java .............................................................................................................................291
DataParser.java............................................................................................................................294
Weather.java ................................................................................................................................305
News.java.....................................................................................................................................311
MoviesList.java ............................................................................................................................319
Summary .............................................................................................................................................328
Chapter 11: Project 6: Target Practice Game..........................................329
User Interface......................................................................................................................................329
How It Works......................................................................................................................................330
Source Code ........................................................................................................................................334
Code explanation.........................................................................................................................339
MainClass.java .............................................................................................................................340
Summary .............................................................................................................................................354
Chapter 12: Converting J2SE Applications to J2ME ..............................355
Issues Involved in Conversion ............................................................................................................355
Differences in Java language support and virtual machines.......................................................355
Differences in the hardware......................................................................................................... 356
Problems due to device variety ................................................................................................... 356
Differences in the application models......................................................................................... 357
Differences in APIs...................................................................................................................... 357
What Conversion Entails .................................................................................................................... 358
Modifying the application design, if necessary .......................................................................... 358
Reducing the GUI ........................................................................................................................ 358
Removing unnecessary or impossible functionality................................................................... 359
Optimizing the use of resources .................................................................................................. 359
Using JavaCheck ................................................................................................................................ 359
An Example of Conversion................................................................................................................. 361
Analyzing the design ................................................................................................................... 361
Reducing the GUI ........................................................................................................................ 362
Is some functionality unnecessary or impossible? ..................................................................... 363
Listing the items consuming resources ....................................................................................... 364
Testing the application................................................................................................................. 365
Summary............................................................................................................................................. 365
Appendix A: About the CD-ROM ..............................................................366
System Requirements......................................................................................................................... 366
What’s on the CD............................................................................................................................... 366
Source code................................................................................................................................. 366
Applications ................................................................................................................................ 367
E-Book ........................................................................................................................................ 367
Troubleshooting.................................................................................................................................. 367
Index ...........................................................................................................369
End User License Agreement...................................................................377
Sun Microsystems, Inc. Binary Code License Agreement.....................379
License Agreement: Forte for Java, Release 2.0 Community Edition
for All Platforms ......................................................................................382

Download
Another J2ME Books
Another Wireless Network Books
Another Hacker Books

Friday, September 3, 2010

Micro JAVA Game Development












Table of Content
Table of Content .................................................................................................................. i
Copyright.............................................................................................................................. i
Trademarks..................................................................................................................... i
Warning and Disclaimer................................................................................................. i
Credits............................................................................................................................. ii
Dedication ...................................................................................................................... iii
About the Author................................................................................................................ iii
Acknowledgments ............................................................................................................. iii
Chapter 1. Introduction (or Everything I Wanted to Know About Micro Java Gaming
But Was Afraid to Ask)....................................................................................................... 1
A New Era of Gaming.................................................................................................... 1
This Book's Mission ....................................................................................................... 3
A Bit About Game Design............................................................................................. 6
Show Me the Money: Micro Game Business Models............................................. 16
Summary ....................................................................................................................... 18
Part I: Small Devices ................................................................................................19
Chapter 2. The Mobile World.......................................................................................... 20
A New Era of Gaming.................................................................................................. 20
High-End Java Devices: Set-Top Boxes, Phones, Consoles................................ 22
Personal Digital Assistants (PDAs) ........................................................................... 24
Mobile Phones and Pagers ........................................................................................ 31
Low-End Java Devices: Smart Cards and Embedded Chips................................ 40
Summary ....................................................................................................................... 41
Chapter 3. Big Games, Small Screens ......................................................................... 42
Your Competition ......................................................................................................... 42
WAP Games ................................................................................................................. 43
i-mode Games .............................................................................................................. 54
SMS Games.................................................................................................................. 55
J2ME MIDP Games..................................................................................................... 57
J2ME Palm Games...................................................................................................... 65
iAppli Games................................................................................................................. 67
What Are You Waiting For?........................................................................................ 74
Part II: Before, Between, and Beyond J2ME........................................................75
Chapter 4. Wireless Standards: How Data Goes To And Fro................................... 76
Wireless Networks ....................................................................................................... 76
The Wireless Application Protocol (WAP)................................................................ 78
Server-Side WAP......................................................................................................... 95
Handheld Device Markup Language (HDML)........................................................ 102
WAP 2.0 and xHTML Basic...................................................................................... 105
Summary ..................................................................................................................... 106
Chapter 5. Let's Talk: Instant Wireless Messaging................................................... 107
Messaging And Gaming............................................................................................ 107
Short Message Service (SMS)................................................................................. 108
Actually Sending SMS Messages............................................................................ 112
SMS and J2ME........................................................................................................... 113
Multimedia Messaging Service (MMS) ................................................................... 115
Summary ..................................................................................................................... 117
Chapter 6. Wireless in Asia: i-mode and cHTML ...................................................... 118
Using i-mode............................................................................................................... 118
Compact HTML (cHTML).......................................................................................... 119
Development Tools.................................................................................................... 125
Testing and Emulators .............................................................................................. 125
Summary ..................................................................................................................... 128
Chapter 7. The Wireless Landscape........................................................................... 129
Bluetooth ..................................................................................................................... 129
Mobile Positioning...................................................................................................... 131
m-Commerce .............................................................................................................. 135
Voice and Telephony................................................................................................. 137
Unified Messaging (UM)............................................................................................ 138
Summary ..................................................................................................................... 138
Part III: The Java 2 Micro Edition..........................................................................140
Chapter 8. J2ME Overview........................................................................................... 141
The Trinity of Java Platforms.................................................................................... 141
It's a Small World After All ........................................................................................ 142
Profiles and Configurations ...................................................................................... 143
Connected in a Limited Way: The CLDC ............................................................... 147
The Mobile Profile ...................................................................................................... 148
Summary ..................................................................................................................... 149
Chapter 9. Creating a MIDlet........................................................................................ 150
Command-Line MIDlet Development...................................................................... 150
Development Environments ..................................................................................... 152
Lifecycle of a MIDlet .................................................................................................. 156
Displaying Stuff........................................................................................................... 157
Menus and Commands............................................................................................. 161
Creating Help and About Alert Screens.................................................................. 164
Global Properties ....................................................................................................... 168
Summary ..................................................................................................................... 169
Chapter 10. Making the Most of Limited Resources................................................. 171
The Limitations ........................................................................................................... 171
Memory Limitations.................................................................................................... 172
Displays ....................................................................................................................... 174
Breaking Through the Limitations............................................................................ 175
Summary ..................................................................................................................... 176
Chapter 11. Making the Most of It: Optimizations ..................................................... 177
A Limited World .......................................................................................................... 177
Making Code Optimal................................................................................................ 177
Code Size Reductions............................................................................................... 178
Speeding Up the Code.............................................................................................. 182
Using Less Memory................................................................................................... 185
Power Consumption .................................................................................................. 187
Summary ..................................................................................................................... 187
Chapter 12. Multithreaded Game Programming........................................................ 188
Threads........................................................................................................................ 188
Extending the Thread Object.................................................................................. 189
Implementing the Runnable Interface................................................................... 190
Thread Priorities......................................................................................................... 192
Thread States ............................................................................................................. 192
Synchronizations and Deadlocks ............................................................................ 192
wait() and notify()............................................................................................ 193
Timers .......................................................................................................................... 194
Making Threads Better.............................................................................................. 195
Summary ..................................................................................................................... 196
Part IV: Let the Games Begin! ..............................................................................198
Chapter 13. High-Level Graphical User Interfaces ................................................... 199
The Screen Class..................................................................................................... 199
Forms and Alerts........................................................................................................ 200
Lists .............................................................................................................................. 200
Text Boxes .................................................................................................................. 204
Items............................................................................................................................ 205
Tickers ......................................................................................................................... 212
Additional Libraries .................................................................................................... 212
Summary ..................................................................................................................... 213
Chapter 14. Working with Graphics: Low-Level Graphical User Interfaces .......... 214
The Canvas Class..................................................................................................... 214
Painting on the Screen.............................................................................................. 217
Drawing Images ......................................................................................................... 223
Summary ..................................................................................................................... 226
Chapter 15. Entering the Land of Sprites ................................................................... 227
Sprites......................................................................................................................... 227
Image Files.................................................................................................................. 231
Collision Detection ..................................................................................................... 233
Creating Child Sprites ............................................................................................... 235
Image Transparency.................................................................................................. 236
Summary ..................................................................................................................... 239
Chapter 16. Managing Your Sprites ............................................................................ 240
Networked Game Components................................................................................ 240
Advanced Collision Detection .................................................................................. 242
The Sprite Manager ................................................................................................... 245
Summary ..................................................................................................................... 248
Chapter 17. Sprite Movement....................................................................................... 249
Floating-Point in J2ME.............................................................................................. 249
Game Initialization ..................................................................................................... 255
Movement.................................................................................................................... 256
Piecing It All Together ............................................................................................... 258
Summary ..................................................................................................................... 261
Chapter 18. J2ME Audio Basics .................................................................................. 262
Sounds Are (Barely) Possible! ................................................................................. 262
Summary ..................................................................................................................... 263
Chapter 19. Be Persistent: MIDP Data Storage ........................................................ 265
RecordStore Overview .......................................................................................... 265
RecordStore in Practice ........................................................................................ 266
More RecordStore Joy .......................................................................................... 273
Summary ..................................................................................................................... 278
Chapter 20. Connecting Out: Wireless Networking .................................................. 279
J2ME Networking Overview ..................................................................................... 279
MIDP Networking ....................................................................................................... 281
Setting Up Your Game Server ................................................................................. 285
Data Format ................................................................................................................ 286
Making a Multiplayer Car Racing Game................................................................. 289
Summary ..................................................................................................................... 315
Part V: J2ME Extensions .......................................................................................316
Chapter 21. PersonalJava, Connected Device Configuration, and Other Micro Java
Blends .............................................................................................................................. 317
Connected Device Configuration (CDC) ................................................................ 317
PersonalJava .............................................................................................................. 318
PDA Profile.................................................................................................................. 323
Java Game Profile ..................................................................................................... 324
The J2ME Multimedia Profile ................................................................................... 324
Summary ..................................................................................................................... 325
Chapter 22. iAppli: Micro Java with a Twist................................................................ 326
The Architecture of It All............................................................................................ 326
iAppli: Like MIDP, But Not Quite.............................................................................. 330
Developing iApplis ..................................................................................................... 341
Summary ..................................................................................................................... 343
Chapter 23. Siemens Game API.................................................................................. 345
Getting Set Up ............................................................................................................ 345
The Game SDK Overview ........................................................................................ 348
Images and Sprites.................................................................................................... 348
Graphic Objects.......................................................................................................... 350
Sprites......................................................................................................................... 350
TiledBackground .................................................................................................. 353
Flashing ....................................................................................................................... 356
Good Vibrations.......................................................................................................... 357
Music, Sweet Music ................................................................................................... 357
GSM Functions........................................................................................................... 360
Input Output ................................................................................................................ 361
Summary ..................................................................................................................... 362
Part VI: Micro Racer................................................................................................364
Chapter 24. Micro Racer: Putting It All Together....................................................... 365
The Bad News ............................................................................................................ 365
The Good News ......................................................................................................... 366
Putting Together the Pieces ..................................................................................... 366
One Game Running Everywhere............................................................................. 383
Summary ..................................................................................................................... 385
Part VII: Appendixes ...............................................................................................386
Appendix A. Low-Level GUI Classes .......................................................................... 387
Game Classes ............................................................................................................ 387
javax.microedition.lcdui.AlertType..................................................... 388
javax.microedition.lcdui.Command.......................................................... 389
javax.microedition.lcdui.Display.......................................................... 389
javax.microedition.lcdui.Displayable ................................................ 389
javax.microedition.lcdui.Canvas ............................................................ 389
javax.microedition.lcdui.Screen ............................................................ 390
javax.microedition.lcdui.Alert............................................................... 390
javax.microedition.lcdui.Form................................................................. 390
javax.microedition.lcdui.List................................................................. 390
javax.microedition.lcdui.TextBox.......................................................... 391
javax.microedition.lcdui.Font................................................................. 391
javax.microedition.lcdui.Graphics ....................................................... 392
javax.microedition.lcdui.Image............................................................... 392
javax.microedition.lcdui.Item................................................................. 393
javax.microedition.lcdui.ChoiceGroup ................................................ 393
javax.microedition.lcdui.DateField..................................................... 393
javax.microedition.lcdui.Gauge............................................................... 393
javax.microedition.lcdui.ImageItem..................................................... 394
javax.microedition.lcdui.StringItem................................................... 394
javax.microedition.lcdui.TextField..................................................... 394
javax.microedition.lcdui.Ticker ............................................................ 394
Appendix B. MIDP 1.1 ................................................................................................... 395
Main Packages........................................................................................................... 395
java.io Class Hierarchy ...................................................................................... 395
java.io Interface Hierarchy ................................................................................ 396
java.lang Class Hierarchy ................................................................................. 396
java.lang Interface Hierarchy............................................................................ 397
java.util Class Hierarchy ................................................................................. 397
java.util Interface Hierarchy............................................................................ 397
javax.microedition.io Class Hierarchy..................................................... 397
javax.microedition.io Interface Hierarchy............................................... 397
javax.microedition.lcdui Class Hierarchy.............................................. 398
javax.microedition.lcdui Interface Hierarchy........................................ 398
javax.microedition.midlet Class Hierarchy ........................................... 398
javax.microedition.rms Class Hierarchy .................................................. 398
javax.microedition.rms Interface Hierarchy ............................................ 398
Appendix C. Siemens Game API................................................................................. 400
Game Classes ............................................................................................................ 400
Siemens GSM Classes ............................................................................................. 402
Input/Output Classes ................................................................................................. 402
Appendix D. The iAppli API........................................................................................... 404
Packages..................................................................................................................... 404
com.nttdocomo.io Interfaces............................................................................ 404
com.nttdocomo.io Interfaces............................................................................ 404
com.nttdocomo.lang ........................................................................................... 405
com.nttdocomo.net.............................................................................................. 405
com.nttdocomo.ui................................................................................................ 405
com.nttdocomo.ui Interfaces............................................................................ 406
com.nttdocomo.util ........................................................................................... 407
com.nttdocomo.util Interfaces ....................................................................... 407
IApplication.......................................................................................................... 408

Download
Another J2ME Books
Related Posts with Thumbnails

Put Your Ads Here!