我正在尝试添加声音,但出现错误:Cannot resolve method 'create(com.game.tobias.game.Explosion, int'为什么要int?

码:

MediaPlayer explosion;
explosion = MediaPlayer.create(this, R.raw.mpExplosion)
explosion.start();

最佳答案

尝试使用getApplicationContext()获取上下文:

MediaPlayer explosion;
explosion = MediaPlayer.create(getApplicationContext(), R.raw.mpExplosion)
explosion.start();

10-05 17:45