libGdx专题

游戏音效渐变

2022-03-15  本文已影响0人  大旺旺的弟弟小旺旺

车游戏,需要在开始的时候音效小,后面的时候音效大。比如跟车速有关,开始小车speed为0 ,音效为0,随
着speed增大,音效的声音也随着增大。


soundpool的pitch方法
Changes the pitch multiplier of the sound instance with the given id as returned by {@link #play()} or {@link #play(float)}.If the sound is no longer playing, this has no effect. @param soundId the sound id @param pitch the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0

可以使用下面的方式来控制。

sound.setPitch(carBody.getLinearVelocity().len() / 19.0F);
上一篇 下一篇

猜你喜欢

热点阅读