From 9294856b03848fa5b22f16093c0849de76811ec4 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 11 Dec 2024 10:02:32 -0600 Subject: [PATCH] add getSoundAddExt (#3311) --- flixel/system/frontEnds/AssetFrontEnd.hx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/flixel/system/frontEnds/AssetFrontEnd.hx b/flixel/system/frontEnds/AssetFrontEnd.hx index d233683759..6c2d7cf3a9 100644 --- a/flixel/system/frontEnds/AssetFrontEnd.hx +++ b/flixel/system/frontEnds/AssetFrontEnd.hx @@ -343,6 +343,22 @@ class AssetFrontEnd return cast getAsset(id, SOUND, useCache, logStyle); } + /** + * Gets an instance of a sound, logs when the asset is not found + * + * @param id The ID or asset path for the sound + * @param useCache Whether to allow use of the asset cache (if one exists) + * @param logStyle How to log, if the asset is not found. Uses `LogStyle.ERROR` by default + * @return A new `Sound` object Note: Dos not return a `FlxSound` + */ + public inline function getSoundAddExt(id:String, useCache = true, ?logStyle:LogStyle):Sound + { + if (!id.endsWith(".mp3") && !id.endsWith(".ogg") && !id.endsWith(".wav")) + id += "." + #if flash "mp3" #else "ogg" #end; + + return getSound(id, useCache, logStyle); + } + /** * Gets the contents of a text-based asset. Unlike its "safe" counterpart, there is no log * on missing assets