1

我正在研究“开始的 Android 游戏”一书,但由于 Eclipse 标记了一个小错误,我真的被卡住了,无法进步。请有人告诉我此代码段是否有任何问题:-

  public Music newMusic(String filename) {
  try {
  AssetFileDescriptor assetDescriptor = assets.openFd(filename);
  return new AndroidMusic(assetDescriptor);
  } catch (IOException e) {
  throw new RuntimeException("Couldn't load music '" + filename + "'");
  }
  }

'AndroidMusic' 被加下划线,Eclipse 说它无法解析为一个类型,并建议我为它创建一个类......我只是不知道该怎么做,这本书的作者没有告诉我创建为它上一堂课。

我真的希望有人能看到我哪里出错了......我期待很快收到你的来信。

4

1 回答 1

2

A simple search for "beginning android games" androidmusic indicates:

  • The book does describe an AndroidMusic class

  • The source code for the book has an AndroidMusic class

In fact, based on that search, it would appear that if you read ahead a few pages from where you were told to enter in the code from your question, the author will show you how to implement that AndroidMusic class.

于 2013-08-17T14:48:54.523 回答