chore:清理空的占位文件
- 删除sprites目录下的空.gitkeep文件 - 删除tools目录下的空README.md文件
This commit is contained in:
@@ -1 +0,0 @@
|
||||
# 保持目录结构 - 角色精灵资源目录
|
||||
@@ -1 +0,0 @@
|
||||
# 保持目录结构 - 特效精灵资源目录
|
||||
@@ -1 +0,0 @@
|
||||
# 保持目录结构 - 环境精灵资源目录
|
||||
191
tools/README.md
191
tools/README.md
@@ -1,191 +0,0 @@
|
||||
# 🛠️ 构建和部署工具
|
||||
|
||||
本目录包含项目的构建和部署脚本。
|
||||
|
||||
---
|
||||
|
||||
## 📦 Web 构建工具
|
||||
|
||||
### build_web.sh (Linux/macOS)
|
||||
### build_web.bat (Windows)
|
||||
|
||||
**功能**: 将 Godot 项目导出为 Web 版本
|
||||
|
||||
#### 使用方法
|
||||
|
||||
**macOS/Linux:**
|
||||
```bash
|
||||
chmod +x tools/build_web.sh
|
||||
./tools/build_web.sh
|
||||
```
|
||||
|
||||
**Windows:**
|
||||
```cmd
|
||||
tools\build_web.bat
|
||||
```
|
||||
|
||||
#### 输出目录
|
||||
- `build/web/` - 导出的 Web 游戏文件
|
||||
|
||||
#### 导出内容包括:
|
||||
- `index.html` - Web 入口文件
|
||||
- `index.js` - 游戏主逻辑
|
||||
- `index.wasm` - WebAssembly 文件
|
||||
- `index.pck` - 游戏资源包
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Web 测试服务器
|
||||
|
||||
### serve_web.sh (Linux/macOS)
|
||||
### serve_web.bat (Windows)
|
||||
|
||||
**功能**: 启动本地 HTTP 服务器预览 Web 游戏
|
||||
|
||||
#### 使用方法
|
||||
|
||||
**macOS/Linux:**
|
||||
```bash
|
||||
chmod +x tools/serve_web.sh
|
||||
./tools/serve_web.sh
|
||||
```
|
||||
|
||||
**Windows:**
|
||||
```cmd
|
||||
tools\serve_web.bat
|
||||
```
|
||||
|
||||
#### 访问地址
|
||||
- 默认: `http://localhost:8000`
|
||||
- 浏览器会自动打开
|
||||
|
||||
#### 注意事项
|
||||
⚠️ **必须使用 HTTP 服务器**
|
||||
- 不能直接用 `file://` 打开 `index.html`
|
||||
- Godot Web 版本需要 HTTP 环境
|
||||
- 本服务器已配置正确的 CORS 头
|
||||
|
||||
---
|
||||
|
||||
## 🔧 配置说明
|
||||
|
||||
### 修改 Godot 路径
|
||||
|
||||
编辑脚本中的 `GODOT_PATH` 变量:
|
||||
|
||||
**macOS:**
|
||||
```bash
|
||||
GODOT_PATH="/usr/local/bin/godot" # Homebrew
|
||||
# 或
|
||||
GODOT_PATH="$HOME/Applications/Godot.app/Contents/MacOS/Godot" # 应用程序
|
||||
```
|
||||
|
||||
**Windows:**
|
||||
```batch
|
||||
set GODOT_PATH=C:\Program Files\Godot\godot.exe
|
||||
```
|
||||
|
||||
**Linux:**
|
||||
```bash
|
||||
GODOT_PATH="/usr/bin/godot" # 包管理器
|
||||
# 或
|
||||
GODOT_PATH="$HOME/bin/godot" # 手动安装
|
||||
```
|
||||
|
||||
### 修改端口
|
||||
|
||||
编辑 `serve_web.sh` 或 `serve_web.bat` 中的端口配置:
|
||||
```bash
|
||||
PORT=8080 # 改为其他端口
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 典型工作流程
|
||||
|
||||
### 1. 开发阶段
|
||||
在 Godot 编辑器中开发和测试游戏
|
||||
|
||||
### 2. 导出 Web 版本
|
||||
```bash
|
||||
./tools/build_web.sh
|
||||
```
|
||||
|
||||
### 3. 本地测试
|
||||
```bash
|
||||
./tools/serve_web.sh
|
||||
# 浏览器访问 http://localhost:8000
|
||||
```
|
||||
|
||||
### 4. 部署到服务器
|
||||
将 `build/web/` 目录的内容上传到你的 Web 服务器
|
||||
|
||||
---
|
||||
|
||||
## 🌍 部署平台示例
|
||||
|
||||
### GitHub Pages
|
||||
```bash
|
||||
./tools/build_web.sh
|
||||
# 将 build/web/ 推送到 gh-pages 分支
|
||||
```
|
||||
|
||||
### Netlify
|
||||
```bash
|
||||
# 直接拖拽 build/web/ 目录到 Netlify
|
||||
```
|
||||
|
||||
### Vercel
|
||||
```bash
|
||||
./tools/build_web.sh
|
||||
vercel --prod build/web/
|
||||
```
|
||||
|
||||
### 自己的服务器
|
||||
```bash
|
||||
scp -r build/web/* user@server:/var/www/html/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 常见问题
|
||||
|
||||
### 问题 1: 找不到 Godot
|
||||
**解决方案**: 修改脚本中的 `GODOT_PATH` 变量
|
||||
|
||||
### 问题 2: 权限不足 (macOS/Linux)
|
||||
**解决方案**:
|
||||
```bash
|
||||
chmod +x tools/build_web.sh tools/serve_web.sh
|
||||
```
|
||||
|
||||
### 问题 3: 浏览器无法加载游戏
|
||||
**原因**: 必须使用 HTTP 服务器,不能用 `file://`
|
||||
**解决方案**: 使用 `serve_web.sh` 启动本地服务器
|
||||
|
||||
### 问题 4: 游戏黑屏
|
||||
**检查**:
|
||||
- 浏览器控制台是否有错误
|
||||
- WebAssembly 是否启用
|
||||
- 是否在 HTTPS 或 localhost 环境下运行
|
||||
|
||||
---
|
||||
|
||||
## 📚 相关文档
|
||||
|
||||
- [Godot Web 导出文档](https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_web.html)
|
||||
- [Web 服务器配置](https://docs.godotengine.org/en/stable/tutorials/export/binary_files_for_web_games.html)
|
||||
- [项目 Web 部署指南](../docs/web_deployment_guide.md)
|
||||
|
||||
---
|
||||
|
||||
## 🎯 下一步
|
||||
|
||||
1. 确保安装了 Godot 4.5+
|
||||
2. 运行 `./tools/build_web.sh` 测试导出
|
||||
3. 运行 `./tools/serve_web.sh` 本地预览
|
||||
4. 根据需要修改配置参数
|
||||
|
||||
---
|
||||
|
||||
**祝你发布顺利!** 🚀
|
||||
Reference in New Issue
Block a user