PDA

View Full Version : Hints for writing MIDlets...



savage
09-02-2006, 12:29 PM
Taken from http://en.wikipedia.org/wiki/MIDlet...

* Handsets impose a limit on the .jar file size. Nokia series 40, arguably the most popular handsets for mobile gaming, has a .jar file size limit of 64kB. The MIDlet size can be reduced through application of programmatic and design optimization techniques ( J2ME Optimizations. J2ME Optimizations. URL accessed on Oct 10, 2005.) and the use of obfuscators, PNG optimizers, and J2ME optimizers.
* Heap sizes can be very small, around 200kb. Therefore, use as few objects as possible and delete references to them when they are no longer needed. Some image formats such as png will decompress to enormous sizes when loaded so don't keep too many of them. Catching OutOfMemoryErrors exceptions will normally not work.
* Programs can not expect more than 20kb persistent storage. Don't keep more than you need. (Newer phones support additional APIs for file storing)
* Keep in mind that a device can have very different screen dimensions, orientations and color depths. In other words, don't use absolute position.
* Not all devices have keypads or pointers. One should be able to use the program with both. Key layouts may vary too, so use Game Actions for up-down-left-right-action style events.
* Don't white list devices. If the program hasn't been tested on a specific device, assume it works. Never attempt to block the user from trying it.
* Use an obfuscator such as Proguard( http://proguard.sourceforge.net/ ) to compress the MIDlet size.

When using MIDletPascal...
* Dont use params passed by reference, in the Java emulator the application crushes befor start Shocked
* Using an array of record type may be derived in a bug
* ImageFromImage() loses transparency information when compiling for MIDP1.0
* http://piligrim.at.tut.by/java/ - Gaming API Support 1.1 for MIDletPascal
* http://developers.sun.com/techtopics/mobility/midp/reference/techart/ - for Java list of MIDP articles

EugenioEnko
09-02-2006, 12:42 PM
*Try to load all resource file in the application start up, becouse the accesing to mobil flash memory may be very slow.

savage
15-02-2006, 10:44 AM
* MIDletPascal supports the following if constuct...


if value1 <> value2 then
Statement1; // Note ; at end
else
statement2;


But it also allows classic pascal syntax...


if value1 <> value2 then
Statement1
else
statement2;

savage
21-02-2006, 03:26 PM
* ReadLine has a bug where it does not find the end of file. In my case this caused an endless loop. As a work around you may want to add "END" to the end of your text files. Something similar to the following code should do the trick...


procedure LoadLevel&#40; aLevel &#58; string &#41;;
var
res &#58; resource;
line &#58; string;
begin
// Levels
res &#58;= OpenResource&#40; '/' + aLevel + '.txt' &#41;;
if &#40;resourceAvailable&#40;res&#41;&#41; then
begin
line &#58;= ReadLine&#40;res&#41; ;

iCounterY &#58;= 0;
while line <> 'END' do
begin
// Populate the Array
for iCounterX &#58;= 0 to MAP_WIDTH do
begin

end;
// Read Next line
line &#58;= ReadLine&#40;res&#41;;
iCounterY &#58;= iCounterY + 1;
end;

CloseResource&#40;res&#41;;
end;
end;