How do I develop Java games for phones? - java

How do I begin developing J2ME games for mobile phones?
Are any libraries available that can render pixel fonts for text? - for text games
Are 2D graphic libraries available that can draw animated bitmaps? - for isometric and tiled games
Any are 3D engines available with texture mapping & lighting? -- for racing and flying simulators
And regarding screen sizes:
What screen size to choose initially for good market penetration?
How to manage game source code, in different screen sizes? Make separate branches?
I'm new to J2ME programming, so any links you can give me to start off would be great.

Game Programming Crash Course to begin developing simple bitmap games.

Screen size of 240x320 pixels is where most j2me-enabled phones are these days.
Obviously, touchscreen phones usually have bigger screens than this. A VGA size of 480x640 is just around the corner for high-end phones.
Different screen sizes are usually handled by having generic code that can handle any screen size and can modify layout depending on in-Jar configuration files. You then simply make several jar files, all containing the same compiled code but different values in the configuration files.
For 3D graphics, a lot of phones these days support http://www.jcp.org/en/jsr/detail?id=184.
Recent Sony-Ericsson phones also have http://www.jcp.org/en/jsr/detail?id=239 which should be easier to use if you already know OpenGL. 3D performances vary widly between phones that contain a hardware accelerator chip and those that don't.
Animated bitmaps on J2ME usually means making you're own redrawing thread to refresh the screen. The only image format officially supported by the MIDP specification is PNG.
Because of this last fact, if you want to create your own pixel font, you are pretty much going to need to have each character in a PNG image.
You might want to look at LWUIT, an open source library published by Sun.

I know this isn't a direct answer to your question, but I think J2ME is slowly on the decline, and Android is taking its place. You may want to take a look at the iPhone as well, even though it's not Java. For the iPhone, you're looking at 480x320 screen size and you can use Cocos2D for the 2D games.
Also check out Kevin Glass's website, which has a lot of notes about 3-way instantaneous deployment to Applet, Android, and iPhone. More details are here.

There's this incredible list of open source J2ME libraries that do all sorts of things, like UI, Graphics, Games, 3D, Bluetooth, SMS, IM, Math, Security, Databases, XML .. even Dev Tools.
Java ME Open Source Software - ngPhone

Related

Image Sizes for Themes

I'm looking at making my own theme in CodenameOne but I cant find out quite what I need to do (I should point out I'm new to codename one)
From what I can see the key to what I need to do revolves around Multi-Images. I place an image there and the designer scales it multiple times so that I have all the images needed for the multitude of devices. Clearly, if it's scaling, the exact size of the image I put in Multi Image is a little irrelevant but what is the optimum size (presumably the close to the largest dimensions that will be used?). Can anyone give me an idea about the resolution of, say, a background image that I'm going to put into Multi Image and the correct (or best) aspect ratio?
Historically we recommended making retina iPhone sized images then importing them using the "Quick Add Multi Image" menu option and picking "Very High" as the target DPI.
This still works rather well but recently there has been an influx of higher DPI devices (iPhone 6+ and newer Android flagships) so we might update that guideline in the near future.

Why my project works on android but not on ios in codenameone?

I work on a big project with codenameone(i can't attach my codes because it's really big). I get android app and it's works on android devices. But recently i get ios build for this project and it's not working on ios device(just showing a white page instead of map).
My project is a map-framework that render tiles and ... on graphics(i used graphics class for drawing, transforming, writing text and more).
I used input stream for working with file because of File not supported.
I need a solution to how debug and find my problem about ios build(why tiles doesn't showed).
In fact i don'n know anything about ios and objective-c.
Thanks in advance.
Most of the logging functionality that allows inspecting issues is for pro developers (you can try the trial) its discussed in this video (mostly focused on crashes): http://www.codenameone.com/how-do-i---use-crash-protection-get-device-logs.html
From your description I would guess you created a really large mutable image (larger than screen bounds) and are drawing onto that. This would be both slow on iOS (and on newer Android devices) and might actually produce that result if the image exceeds the maximum texture size of the device.
If that is not the case you would need to explain what you are doing more precisely.

What kind of image formats should I use in an Android application?

I'm writing a game for Android and I was wondering what kind of images should I use for the in game graphics.
I told the customer to create the artwork in the highest possible (and reasonable) resolution and I will scale it down but I have been told lately that SVG would be better than plain PNG for example since there are a lot of resolutions used by Android devices and the images have to be scaled. Most of the graphics will be stationary backgorunds or objects but there will be some animations. I will use AnimationDrawable for this.
Is there some general guideline for graphical file formats (I checked out android developer site but didn't find anything) or just go with whatever I have at the moment?
I have been told lately that SVG would be better than plain PNG for example
Android does not support SVG natively. There are third-party libraries that support SVG, such as this one.
since there are a lot of resolutions used by Android devices and the images have to be scaled
If that is literally what your graphic designer told you, you need to hire a different graphic designer. Quickly.
Resolution is typically meaningless. What matters is screen size and, more importantly for graphics, screen density. Android supports multiple versions of an image for different densities, and can also resample images from one density into another, so you can "dial in" how many densities you wish to support directly. Here is a blog post from yesterday regarding screen density, and there is plenty of material in the Android documentation on this as well.
Now, your graphic designer might use SVG "internally" and generate density-scaled PNG files for your use -- that is perfectly reasonable.
Is there some general guideline for graphical file formats
Yes, here. It says
Android supports bitmap files in a three formats: .png (preferred), .jpg (acceptable), .gif (discouraged).
There is no native support for SVG drawables but there are libraries that support SVG
See SVG support on Android
You would typically convert SVG images to pixel images for each density. Android also defines some standard sizes for icons like Menu icons
Having the sources for the images you use as SVG is not a bad idea. SVG and other vector based graphics usually scale better to different sizes than pixel graphics. Especially if you need to enlarge an image (for example for the hi-res icons used in the Play store).
Also be careful with AnimationDrawable, it is not meant to be used for fullscreen animations. Just small animated icons and such.

Android animation flash vs. HTML5 vs. Android's native animation library?

I am going to be writing a tower defense game for Android phones. I have knowledge of Java and the Android SDK; however, I am new to animation and have a few questions about where to start.
I will be using only 2D graphics (maybe later down the road 3D graphics but for now I will keep it simple), have basic animations (enemies moving along pre-determined paths, stationary towers shooting at moving enemies, and maybe a few explosions here and there), and some sounds that result from different in game actions. Just to give you a rough idea of what I am thinking about, my game would be very similar to bloons tower defense 4.
My question is, based on what I have stated above would you suggest I incorporate Flash, HTML5, or Android's native animation libraries? What are the pros and cons of using each one? If none of these are good options than what is?
I'd suggest using Android's native libraries. Adobe has already said they're not longer going to support flash on Android so you'll slowly users over time. And beside, Android's native libraries are going to give you better performance anyway. In addition, there are some really nice frameworks out there that make developing games on android with OpenGL super easy (see andengine or this Gamers post for more details).
As far as HTML5 goes, I'd say stay away from it. Most users prefer a native app over a web-app and I can almost guarantee you that you're going to get better performance with a native app.
1) If you are going to make games, use definitely the Java. It is fast, there are plenty of game physic libraries, you can use OpenGL and you can even use C ports of some famous game libraries. You are simply not limited.
2) The HTML5 is pretty slow so far and no matter how good it is for mobile web pages, it is not sufficient for more complex games then Tetris or Sudoku. Just try some HTML games on couple of Android devices - nothing is better then own experience.
3) Do not start with Flash - Adobe company closes the Flash support in mobile phones. See there or there. This is releted to the Flash support in browsers.
4) As mentioned in one comment below - the Adobe AIR is other possibility and different story then Flash in web browser. This is Flex based technology (Action script + XML). It allows you creating standalone applications - we have 2 apps with AIR, but the AIR framework is slower then Java, it does not run on certain devices (low-end Androids), you must purchase the Adobe IDE and the developers base is smaller, so it is harder to find answers if you are in troubles. There is no clear advantage over Java, unless you plan to release also for desktop.
Regards,
STeN

Suggested framework for generic 3D demo software

My company has decided that we need a "generic" demo infrastructure for our technology demos, given that I can write this using JOGL or OpenGL and create my own framework, I'd hate to reinvent the wheel. But there are so many 3D gfx engines out there and so many OpenGL wrappers!
Basically, we want to use 3D graphics to render some terrain and put simple models on it.
Their requirements are for it to look great and be cross-platform.
Basically, I am free to decide the scope and paradigm this would follow but I was thinking:
- Be able to load 3D models and render them in full-screen or windowed mode.
- Be able to control the camera(s) to "fly" through the resulting scene.
- Be able to show/hide billboard messages on top of everything, i.e. 2D text and images that are fixed on the screen and always face the camera.
- Be able to change simple things about parts of the scene, such as making object appear/disappear, change highlight color (like paint in red), and such.
- I am optionally looking to write or use an existing scripting language to inject event handling and pre-programmed animations.
Sample use case:
- Someone at our company prepares a 3D model of terrain with some buildings, essentially generating an XML-like file describing the scene and its objects.
- He then proceeds to use my program to fly through the terrain and record a few camera positions "of interest".
- Then, he binds some of those positions to keyboard keys and/or existing GUI buttons.
- He adds some pieces of floating text.
- He presents a demo using my program, loads his 3D model file and script file and can start "flying" with the audience from one of his selected camera poses to the next, the floating text fades in and out as he arrives and leaves the camera positions... some buildings on the terrain highlight in red when he clicks a button... etc.
I have some OpenGL and JOGL, as well as XNA Game Studio experience.
I'd rather use Java so it can be as platform-independent as possible.
What should I do?
I'd recommend you take a look at OpenSceneGraph or Ogre. Both are cross platform (C++), feature rich graphics engines. Furthermore, they are commercially friendly licenses and are very mature and actively maintained engines.
I know that out of the box, OpenSceneGraph supports the loading of several model formats with one or two lines of code and there are several OSG libraries that already do a great job at managing and rendering terrain.
Otherwise, you'll be spending 95% of your time writing a niche engine rather than developing your visualization capability.
It's not Java, but otherwise what you describe sounds extremely close to the Open Source Virtual Terrain Project. You may well be better using that add contributing additional facilities you develop than starting from a more basic scenegraph level.
I advise you to use Ardor3D or JMonkeyEngine 3. Ardor3D has an excellent support of JOGL, it supports the Collada format, terrains, heightmaps, it is used by the NASA and in GIS applications, it is not a niche engine. Ardor3D even works on Android, it is one of the most cross-platform 3D engine.
I advise you to look at this demo showing a procedural terrain in Ardor3D:
http://www.youtube.com/watch?v=bkXFkxrYtLY

Categories