Skip to content

Commit

Permalink
add getSoundAddExt
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Dec 11, 2024
1 parent 3465534 commit 4a9395f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions flixel/system/frontEnds/AssetFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a9395f

Please sign in to comment.