我正在尝试添加声音,但有错误:Cannot resolve method 'create(com.game.tobias.game.Explosion, int
'为什么是int?
代码:
MediaPlayer explosion;
explosion = MediaPlayer.create(this, R.raw.mpExplosion)
explosion.start();
答案 0 :(得分:0)
尝试使用getApplicationContext()
获取上下文:
MediaPlayer explosion;
explosion = MediaPlayer.create(getApplicationContext(), R.raw.mpExplosion)
explosion.start();