mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
SoundEffect's sound should be delayed by its startDelay (#9502)
* SoundEffect's sound should be delayed by its startDelay * h
This commit is contained in:
parent
4e35ae2dec
commit
cc0ac1523b
@ -21,18 +21,32 @@ public class SoundEffect extends Effect{
|
||||
public Effect effect;
|
||||
|
||||
public SoundEffect(){
|
||||
startDelay = -1;
|
||||
}
|
||||
|
||||
public SoundEffect(Sound sound, Effect effect){
|
||||
this();
|
||||
this.sound = sound;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
if(startDelay < 0){
|
||||
startDelay = effect.startDelay;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(float x, float y, float rotation, Color color, Object data){
|
||||
if(!shouldCreate()) return;
|
||||
|
||||
sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume));
|
||||
if(startDelay > 0){
|
||||
Time.run(startDelay, () -> sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume)));
|
||||
}else{
|
||||
sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume));
|
||||
}
|
||||
|
||||
effect.create(x, y, rotation, color, data);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user