forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
BIN
sound/Bundled/hit0.wav
Normal file
BIN
sound/Bundled/hit0.wav
Normal file
Binary file not shown.
BIN
sound/Bundled/hit1.wav
Normal file
BIN
sound/Bundled/hit1.wav
Normal file
Binary file not shown.
BIN
sound/Bundled/hit2.wav
Normal file
BIN
sound/Bundled/hit2.wav
Normal file
Binary file not shown.
6
sound/README.md
Normal file
6
sound/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
- Keyboard `Space`: load/play bundled sound
|
||||
- Keyboard `A`: toggle play/pause positional speaker
|
||||
|
||||
- https://github.com/leenkx3d/leenkx/wiki/sound
|
||||
- https://api.leenkx3d.org/iron/object/SpeakerObject.html
|
||||
- https://api.leenkx3d.org/kha/Sound.html
|
||||
32
sound/Sources/lnx/SoundControl.hx
Normal file
32
sound/Sources/lnx/SoundControl.hx
Normal file
@ -0,0 +1,32 @@
|
||||
package lnx;
|
||||
|
||||
import iron.object.SpeakerObject;
|
||||
import iron.system.Input;
|
||||
|
||||
class SoundControl extends iron.Trait {
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
notifyOnInit(() -> {
|
||||
final mouse = Input.getMouse();
|
||||
final keyboard = Input.getKeyboard();
|
||||
final speaker = iron.Scene.active.getSpeaker('Speaker');
|
||||
trace(speaker.data);
|
||||
notifyOnUpdate( () -> {
|
||||
if(keyboard.started('a')) {
|
||||
trace('Toggle speaker (${!speaker.paused})');
|
||||
speaker.paused ? speaker.play() : speaker.pause();
|
||||
}
|
||||
if(keyboard.started('space')) {
|
||||
// Randomly play one of the three hit sounds
|
||||
final sound = 'hit${Std.random(3)}.wav';
|
||||
trace('Play $sound');
|
||||
iron.data.Data.getSound(sound, (s:kha.Sound) -> {
|
||||
var channel = iron.system.Audio.play(s);
|
||||
channel.volume = 0.4;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
sound/drums.wav
Normal file
BIN
sound/drums.wav
Normal file
Binary file not shown.
BIN
sound/sound.blend
Normal file
BIN
sound/sound.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user