【发布时间】:2020-01-13 05:11:53
【问题描述】:
正如标题所暗示的,我试图在播放某个动画时播放一段声音,我对其他声音没有任何问题,通过使用推论,我得出结论,每次动画的一帧声音都在循环通过。应该是鲨鱼与地雷相撞,地雷爆炸,听到一声巨响,游戏结束。
编辑:只有在检测到碰撞时才会调用 Boom Sound 的代码。当玩家与收藏品发生碰撞时,还有另一种声音,但是 声音工作正常。只有当玩家与地雷碰撞并播放爆炸动画时,声音才会混乱。每次动画帧通过时它都会重新启动。
if (Intersector.overlaps(this.mineC[i], this.sharkC)) {
this.boomsound.play();
this.collision = true;
this.gamestate = 2;
this.runtime += Gdx.graphics.getDeltaTime();
this.game.batch.draw((TextureRegion) this.boom.getKeyFrame(this.runtime, false), (float) (Gdx.graphics.getWidth() / 5), this.sharkY - 120.0f);
this.boom.setPlayMode(PlayMode.NORMAL);
if (this.boom.isAnimationFinished(this.runtime)) {
boomsound.stop();
this.game.setScreen(new GameOverShark(this.game));
}
}
【问题讨论】:
标签: android animation audio libgdx