mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Add basic sounds
This commit is contained in:
@@ -10,7 +10,6 @@ class SoundInstance extends SoundInstanceInterface {
|
||||
constructor(key, url) {
|
||||
super(key, url);
|
||||
this.howl = null;
|
||||
this.instance = null;
|
||||
}
|
||||
|
||||
load() {
|
||||
@@ -25,6 +24,7 @@ class SoundInstance extends SoundInstanceInterface {
|
||||
loop: false,
|
||||
volume: 0,
|
||||
preload: true,
|
||||
pool: 20,
|
||||
onload: () => {
|
||||
resolve();
|
||||
},
|
||||
@@ -43,13 +43,8 @@ class SoundInstance extends SoundInstanceInterface {
|
||||
|
||||
play(volume) {
|
||||
if (this.howl) {
|
||||
if (!this.instance) {
|
||||
this.instance = this.howl.play();
|
||||
} else {
|
||||
this.howl.play(this.instance);
|
||||
this.howl.seek(0, this.instance);
|
||||
}
|
||||
this.howl.volume(volume, this.instance);
|
||||
const instance = this.howl.play();
|
||||
this.howl.volume(volume, instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +52,6 @@ class SoundInstance extends SoundInstanceInterface {
|
||||
if (this.howl) {
|
||||
this.howl.unload();
|
||||
this.howl = null;
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +74,7 @@ class MusicInstance extends MusicInstanceInterface {
|
||||
autoplay: false,
|
||||
loop: true,
|
||||
html5: true,
|
||||
volume: 1,
|
||||
volume: 0.3,
|
||||
preload: true,
|
||||
pool: 2,
|
||||
|
||||
@@ -133,6 +127,12 @@ class MusicInstance extends MusicInstanceInterface {
|
||||
|
||||
export class SoundImplBrowser extends SoundInterface {
|
||||
constructor(app) {
|
||||
Howler.mobileAutoEnable = true;
|
||||
Howler.autoUnlock = true;
|
||||
Howler.autoSuspend = false;
|
||||
Howler.html5PoolSize = 20;
|
||||
Howler.pos(0, 0, 0);
|
||||
|
||||
super(app, SoundInstance, MusicInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@ export const SOUNDS = {
|
||||
dialogOk: "ui/dialog_ok.mp3",
|
||||
swishHide: "ui/ui_swish_hide.mp3",
|
||||
swishShow: "ui/ui_swish_show.mp3",
|
||||
|
||||
levelComplete: "ui/level_complete.mp3",
|
||||
|
||||
placeBuilding: "game/place_building.mp3",
|
||||
placeBelt: "game/place_belt.mp3",
|
||||
};
|
||||
|
||||
export const MUSIC = {
|
||||
mainMenu: "main_menu.mp3",
|
||||
gameBg: "theme_full.mp3",
|
||||
theme: "theme.mp3",
|
||||
};
|
||||
|
||||
export class SoundInstanceInterface {
|
||||
|
||||
Reference in New Issue
Block a user