feat(audio): 添加音频数据库支持及XML解析功能
实现音频数据库系统,支持从XML文件加载音频配置 添加RapidXML库用于XML解析 提供统一的音频查询接口,支持音效、音乐和随机音效组
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <frostbite2D/audio/sound.h>
|
||||
#include <frostbite2D/resource/npk_archive.h>
|
||||
|
||||
#include <frostbite2D/resource/audio_database.h>
|
||||
#include <frostbite2D/resource/sound_pack_archive.h>
|
||||
|
||||
using namespace frostbite2D;
|
||||
@@ -143,6 +144,16 @@ int main(int argc, char **argv) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load music!");
|
||||
}
|
||||
|
||||
auto &audioDB = AudioDatabase::get();
|
||||
audioDB.loadFromFile("assets/audio.xml");
|
||||
|
||||
// ========== 方式 1: 最简单的 API(推荐) ==========
|
||||
std::string path = audioDB.filePath("P_ICECANNON_SHOT");
|
||||
if (!path.empty()) {
|
||||
SDL_Log("=== 方式 1: 直接获取文件路径 ===");
|
||||
SDL_Log("File: %s", path.c_str());
|
||||
}
|
||||
|
||||
app.run();
|
||||
|
||||
app.shutdown();
|
||||
|
||||
Reference in New Issue
Block a user