Java Reference
In-Depth Information
Figure 8.6 Dual menu systems: a) SVG and b) low-resolution graphics
Incidentally, you should be able to see that the menus overlay different
background images. Every time a new game is started, the game randomly
selects a new background from a set of 10 high-resolution images included
in the application JAR file. That becomes the active background for the
entire MIDlet until a new game is played.
There is no particular point to this other than that it varies the feel of the
game increasing its interest level and the pictures look great (they're all
fromNASA). This also shows just one of the things you can do on Symbian
OS when you do not have to operate under the stringent limitations
imposed by other operating systems. You can use your imagination to
come up with an almost endless variety of great effects and features.
8.4.4 Using the Mobile Media API (JSR-135)
Chapter 2 discusses the lifecycle of a Player and demonstrates how to
instantiate, realize, set starting volume and pre-fetch to minimize delay
when the start() method of the player is called, so we won't repeat
that information here. What we are going to show is how to provide
background music without it running all the time. Many games do this
simply because studies have shown that music helps create a more
immersive experience. By interspersing MIDI sequences with periods of
silence we can change the 'feel' of the game in a subtle manner which
helps maintain player interest.
To do this we use timers, some basic parameters and a random-number
generator. We also need to detect when the active sequence has finished
by implementing the PlayerListener interface. Whenever the current
background music stops we wait for a random (bounded) interval of time
and then start the next sequence:
Search WWH ::

Custom Search