06-02-2009 03:39 PM
Our company makes PC games, and is branching out into various other formats; iPhone, Blackberry, etc.
I'm making a Blackberry version of one of our games which is somewhat larger than traditional Blackberry apps. Right now all the assets etc. come out to be about 7 megs (note most of these aren't loaded concurrently, there are multiple screens, phases, etc.) So here are my questions.
1) The documentation seems to imply that there is no limit on COD file size after version 4.0 came out. However, we seem to have hit a wall at about the 6 MB mark. After that I start getting weird errors when I start up the simulator about not being able to find classes like Bitmap and Resource. Once I remove the resources that put me over the limit, everything goes back to working. Can anyone confirm or deny this size limit?
2) I've been able to avoid the first issue by splitting things up into multiple projects. So I have a Library project with the assets for a certain part of the game, and another cod library with assets for another part of the game, plus a cod file with all of the code. This works fine for loading up graphics when I use the Bitmap.getBitmapResource() that also takes a module name. However, now I have an issue with sounds. If I put the game's sounds in a separate cod module, I don't see any mechanism by which I can retrieve them from that module when I need to create the javax.microedition.media.Manager object using the getResourceAsStream(). Does anyone have any experience trying to load a sound from a separate cod module? It seems that no matter what I use I seem to end up with a null stream object. I've tried using a class in the sounds module as the parent of getResourceAsStream() like this...
And the basic getClass().getResourceAsStream(filename) in about every combination I can think of... putting the file at the base level, or nested where I actually want it folder structure wise, using the "/" before the filename (and leaving it off), but no matter what combination I use I end up with a null stream. Any help anybody could give me would be greatly appreciated.
Thanks in advance,
Solved! Go to Solution.
06-02-2009 03:50 PM
PIN: C0001B7B4 Display/Scan Bar Code
PIN: C0005A9AA Display/Scan Bar Code
06-02-2009 04:45 PM - edited 06-02-2009 04:47 PM
If a cod file is bigger than 64Kb (in some rare cases 65-67K) it is splitted to sibling cod files. You get one big cod file that has zip format, and all cod files are inside.
I have no information about size limit of cod files. But I think it is good to make them as small as possible.
You can store resources into cod files and access them from another cod files.
Let say you have a sound file MySong.mid located in MyApp.cod
then you can access this midi file via url: cod://MyApp/MySong.mid
Note that big and small letters does matter.
This approach is not documented but it does work.
In case you have questions related to the Java development post them here:
and check this link:
06-03-2009 12:17 AM
Hey, thanks for the quick answer.
I wasn't able to get the cod:// to work for me, but I like the idea. If you had a code sample I'd like to see it.
However, I was able to fix my problem by having a class with a static method in the library cod file that gets the InputStream object and returns it to the main application in the main cod. Thought I'd post my method in case anybody else runs into a similar issue.
10-13-2011 05:53 AM
# I tried to change the world, but I couldn't find the source code #