Splitting classes in separated files
This commit is contained in:
parent
c17f006992
commit
620bd1ab2c
6 changed files with 85 additions and 82 deletions
|
@ -2,53 +2,11 @@ import type { LoadSoundEvent } from '../Events/LoadSoundEvent';
|
|||
import type { PlaySoundEvent } from '../Events/PlaySoundEvent';
|
||||
import type { StopSoundEvent } from '../Events/StopSoundEvent';
|
||||
import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
|
||||
import SoundConfig = Phaser.Types.Sound.SoundConfig;
|
||||
|
||||
export class Sound {
|
||||
constructor(private url: string) {
|
||||
sendToWorkadventure({
|
||||
"type": 'loadSound',
|
||||
"data": {
|
||||
url: this.url,
|
||||
} as LoadSoundEvent
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public play(config: SoundConfig) {
|
||||
sendToWorkadventure({
|
||||
"type": 'playSound',
|
||||
"data": {
|
||||
url: this.url,
|
||||
config
|
||||
} as PlaySoundEvent
|
||||
|
||||
});
|
||||
return this.url;
|
||||
}
|
||||
public stop() {
|
||||
sendToWorkadventure({
|
||||
"type": 'stopSound',
|
||||
"data": {
|
||||
url: this.url,
|
||||
} as StopSoundEvent
|
||||
|
||||
});
|
||||
return this.url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
import {Sound} from "./Sound/Sound";
|
||||
|
||||
class WorkadventureSoundCommands extends IframeApiContribution<WorkadventureSoundCommands> {
|
||||
|
||||
readonly subObjectIdentifier = "sound"
|
||||
|
||||
readonly addMethodsAtRoot = true
|
||||
callbacks = []
|
||||
|
||||
|
||||
loadSound(url: string): Sound {
|
||||
return new Sound(url);
|
||||
}
|
||||
|
@ -56,4 +14,4 @@ class WorkadventureSoundCommands extends IframeApiContribution<WorkadventureSoun
|
|||
}
|
||||
|
||||
|
||||
export default new WorkadventureSoundCommands();
|
||||
export default new WorkadventureSoundCommands();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue