Game Development Reference
In-Depth Information
W/System.err(17501): at
android.content.res.AssetManager.openFd(AssetManager.java:332)
W/System.err(17501): at
dalvik.system.NativeStart.run(Native Method)
The message is pretty clear: this is a file not found exception. It can't find the Audio/
menu-music.m4a file. A quick check in the Published-Android folder in the Resources
group in Xcode reveals that the audio files for Android have been converted to ogg , not
m4a .
Audio resources will automatically resolve to the correct file extension for each platform
if you use the same extension as the original resource file that was added to SpriteBuilder.
In this case, it would be menu-music.wav , and for all other audio files you need to use the
. wav extension as well, since all audio files were added to SpriteBuilder as .wav files.
The Java exception doesn't indicate what file and line of code the error occurred on. That
can create a little problem finding the source of an exception, but in this case it allows you
to search the project for the menu-music string: press Cmd+Shift+F to search for a string
in all project files.
You'll find the music is referenced in MainScene.m , in the didLoadFromCCB method.
Change the audio file's extension to .wav, as shown in Listing 13-9 .
Listing 13-9 . Playing the correct audio file based on the platform requires using the audio
file's original extension
OALSimpleAudio* audio = [OALSimpleAudio sharedInstance];
[audio playBg:@"Audio/menu-music. wav " loop:YES];
The alternative is to just comment out the line for now. Playing music or effects isn't cru-
cial for the app to work. When this is your first attempt to port your app to Android, you
should make notes of such minor issues, comment out the code, and keep looking for truly
problematic issues. Many tasks, like audio playback, should be fixed at a later time, after
you've fixed worse problems (if there are any). The same goes for not bringing up the
pause menu when the app is paused—again, the app will function fine without it for now.
Note There are other uses of the ObjectAL playBg and playEffect
commands—for example, in the presentGameSceneWithMusic method
in the SceneManager class. They may cause exceptions as well—for in-
Search WWH ::




Custom Search