
|
July 2004 Adding 3D effects to your 2D game
|
|
|
There are two ways of adding 3D effects to your 2D game. You can either use the built-in 3D support (such as found in the K700) or you can simulate 3D by using standard 2D API's. Furthermore, using the Java 3D support in the phone doesn't necessarily mean that all graphics in a MIDlet have to be 3D. Often it makes more sense just to enhance the ordinary 2D game play with small 3D effects. The use of these small effects means that you can keep your core MIDlet code more or less untouched and still get the benefits of 3D. 3D splash screen In the animation thread, the animation is stepped forward frame by frame with the use of a timer in the TimerTask scheduled for repeated fixed-rate execution: myTimer.scheduleAtFixedRate(new TimerTask(){ public void run() { nowFrame += 65536*3; 3D menus Depending on how far you go, the effects may not necessarily require to be created by calls to a 3D engine. For simple effects, you can simply simulate the 3D effects with creative 2D drawing. 3D effects in the game Starting with 2D effects, we can, for example, use a LayerManager to cause transparent layers of clouds or smog to appear to drift in front of each other, thus simulating different distances and creating a sense of depth. The same technique can be applied to the background of a standard horizontal scrolling game by creating two layers of the background and making the front layer move faster than the layer behind it. This is shown in the attached MIDlet. With real 3D support, you can either let the 3D be an active part in the game or just use it in a more passive manner. Active use means that, for example, a spaceship or car controlled by the user is rendered in 3D and reacts to the user input by moving in 3D. Passive use is when you apply the 3D effect more or less independently of user interaction.
| |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.