From b79d76fc2ef41c19692ad7528a19521e8c2ded9f Mon Sep 17 00:00:00 2001 From: "DESKTOP-FMM8UI0\\CLV" Date: Fri, 23 Apr 2021 17:03:17 +0200 Subject: [PATCH] parameter soundConfig is now optionnal if user call mySound.play() the sound will be played with the base SoundConfig --- front/src/Api/Events/PlaySoundEvent.ts | 2 +- front/src/Phaser/Game/SoundManager.ts | 7 ++-- maps/tests/SoundTest.json | 46 ++++++++++++++++++-------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/front/src/Api/Events/PlaySoundEvent.ts b/front/src/Api/Events/PlaySoundEvent.ts index 49b657b1..33ca1ff4 100644 --- a/front/src/Api/Events/PlaySoundEvent.ts +++ b/front/src/Api/Events/PlaySoundEvent.ts @@ -15,7 +15,7 @@ const isSoundConfig = export const isPlaySoundEvent = new tg.IsInterface().withProperties({ url: tg.isString, - config : isSoundConfig, + config : tg.isOptional(isSoundConfig), }).get(); /** diff --git a/front/src/Phaser/Game/SoundManager.ts b/front/src/Phaser/Game/SoundManager.ts index f2ee712b..e4d8b055 100644 --- a/front/src/Phaser/Game/SoundManager.ts +++ b/front/src/Phaser/Game/SoundManager.ts @@ -24,11 +24,10 @@ class SoundManager { return soundPromise; } - public async playSound(loadPlugin: LoaderPlugin, soundManager : BaseSoundManager, soundUrl: string, config: SoundConfig) : Promise { + public async playSound(loadPlugin: LoaderPlugin, soundManager : BaseSoundManager, soundUrl: string, config: SoundConfig|undefined) : Promise { const sound = await this.loadSound(loadPlugin,soundManager,soundUrl); - sound.play(config); - - + if (config === undefined) sound.play(); + else sound.play(config); } public stopSound(soundManager : BaseSoundManager,soundUrl : string){ diff --git a/maps/tests/SoundTest.json b/maps/tests/SoundTest.json index fd04ed70..f1e38761 100644 --- a/maps/tests/SoundTest.json +++ b/maps/tests/SoundTest.json @@ -62,18 +62,6 @@ "x":0, "y":0 }, - { - "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "height":20, - "id":7, - "name":"stopSound", - "opacity":1, - "type":"tilelayer", - "visible":true, - "width":20, - "x":0, - "y":0 - }, { "draworder":"topdown", "id":5, @@ -94,6 +82,38 @@ "width":107.109375, "x":258.4453125, "y":197.018229166667 + }, + { + "height":19.296875, + "id":3, + "name":"", + "rotation":0, + "text": + { + "text":"Bonjour Monde", + "wrap":true + }, + "type":"", + "visible":true, + "width":107.109375, + "x":-348.221354166667, + "y":257.018229166667 + }, + { + "height":55.296875, + "id":4, + "name":"", + "rotation":0, + "text": + { + "text":"Play Sound Loop\nexit Zone Stop Sound \n", + "wrap":true + }, + "type":"", + "visible":true, + "width":176.442708333333, + "x":243.778645833333, + "y":368.3515625 }], "opacity":1, "type":"objectgroup", @@ -102,7 +122,7 @@ "y":0 }], "nextlayerid":8, - "nextobjectid":3, + "nextobjectid":5, "orientation":"orthogonal", "properties":[ {