Files
Frostbite2D/platform/switch.lua
Lenheart ec16aeffa6 feat: 实现游戏摄像机控制器并优化地图系统
重构地图系统,增加摄像机控制器管理相机行为。主要变更包括:
- 新增 GameCameraController 类,支持跟随目标和调试模式
- 重构 GameMap 类,分离相机逻辑到控制器
- 优化地图资源加载和同步逻辑
- 改进动画系统的事件处理
- 添加地图测试场景用于快速验证
2026-04-02 20:07:42 +08:00

92 lines
3.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
target("Frostbite2D")
set_kind("binary")
add_files(path.join(os.projectdir(), "Frostbite2D/src/**.cpp"))
add_files(path.join(os.projectdir(), "Frostbite2D/src/**.c"))
add_includedirs(path.join(os.projectdir(), "Frostbite2D/include"))
add_files(path.join(os.projectdir(), "Game/src/**.cpp"))
add_includedirs(path.join(os.projectdir(), "Game/include"))
-- 检查 DEVKITPRO 环境变量Windows 上使用 C:/devkitPro
local devkitPro = os.getenv("DEVKITPRO") or "L:/Switch/devkitPro"
local devkitA64 = path.join(devkitPro, "devkitA64")
-- 设置工具链路径
set_toolset("cc", path.join(devkitA64, "bin/aarch64-none-elf-gcc.exe"))
set_toolset("cxx", path.join(devkitA64, "bin/aarch64-none-elf-g++.exe"))
set_toolset("ld", path.join(devkitA64, "bin/aarch64-none-elf-g++.exe"))
set_toolset("ar", path.join(devkitA64, "bin/aarch64-none-elf-gcc-ar.exe"))
set_toolset("strip", path.join(devkitA64, "bin/aarch64-none-elf-strip.exe"))
-- 架构标志
local arch_flags = "-march=armv8-a+crc+crypto -mtune=cortex-a57 -fPIE"
add_cxflags(arch_flags)
-- 使用 devkitPro 提供的 switch.specs 文件
add_ldflags("-specs=" .. path.join(devkitPro, "libnx/switch.specs"), "-g", arch_flags)
-- 定义 Switch 平台宏
add_defines("__SWITCH__", "__NX__", "MA_SWITCH", "PFD_SWITCH")
-- SimpleIni 配置:不使用 Windows API
add_defines("SI_NO_CONVERSION")
-- libnx 路径 - 必须在工具链级别添加
add_includedirs(path.join(devkitPro, "libnx/include"))
add_linkdirs(path.join(devkitPro, "libnx/lib"))
-- portlibs 路径EGL + 桌面 OpenGL + SDL2
add_includedirs(path.join(devkitPro, "portlibs/switch/include"))
add_includedirs(path.join(devkitPro, "portlibs/switch/include/SDL2"))
add_linkdirs(path.join(devkitPro, "portlibs/switch/lib"))
add_syslinks("SDL2_mixer", "SDL2_image", "SDL2_ttf", "SDL2", "freetype", "harfbuzz" , "squirrel_static", "sqstdlib_static", "bz2" , "webp", "png", "jpeg", "z", "opusfile", "opus", "vorbisidec", "ogg","modplug", "mpg123", "FLAC", "GLESv2", "EGL", "glapi", "drm_nouveau",{public = true})
add_syslinks("nx", "m")
-- 构建后生成 NRO 文件
after_build(function (target)
local assetHelper = import("build_helpers.assets")
local elf_file = target:targetfile()
local output_dir = path.directory(elf_file)
local nacp_file = path.join(output_dir, "hello_world.nacp")
local nro_file = path.join(output_dir, "hello_world.nro")
local nacptool = path.join(devkitPro, "tools/bin/nacptool.exe")
local elf2nro = path.join(devkitPro, "tools/bin/elf2nro.exe")
local icon_file = path.join(os.projectdir(), "assets/icons/icon.bmp")
if os.isfile(nacptool) and os.isfile(elf2nro) then
os.vrunv(nacptool, {"--create", "Hello World", "Frostbite2D Team", "1.0.0", nacp_file})
local romfs = path.join(example_dir, "romfs")
local icon_param = os.isfile(icon_file) and ("--icon=" .. icon_file) or ""
if os.isdir(romfs) then
os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file, icon_param, "--romfsdir=" .. romfs})
else
os.vrunv(elf2nro, {elf_file, nro_file, "--nacp=" .. nacp_file, icon_param})
end
print("Generated NRO: " .. nro_file)
end
-- 复制 assets 目录
local assets_dir = path.join(os.projectdir(), "Game/assets")
local output_dir = target:targetdir()
local target_assets_dir = path.join(output_dir, "assets")
assetHelper.syncAssets(assets_dir, target_assets_dir)
end)
target_end()
on_run(function (target)
local output_dir = path.directory(target:targetfile())
local nro_file = path.join(output_dir, "hello_world.nro")
os.execv("cmd.exe", {
"/c",
"chcp 65001 >nul & nxlink.exe",
"-s",
"-a", "192.168.200.50",
nro_file
})
end)