0.1.110 • Published 11 months ago
mingmaker-old v0.1.110
MingMaker
一个使用TypeScript编写 专注于2D的游戏引擎
MingMaker 其中 "Ming" 的灵感来源于个人喜欢的一味中草药 "决明子" 中的 "明"。
特性 以及 目标
- 专注于2D
- 组件式
- 高性能
- 跨平台
注意 当前版本不适合生产环境
- 目前处于开发阶段
- 可能存在大量破坏性改动以及bug
- 功能还未完善
- 文档还未编写
- 单元测试未编写
当前版本功能 可用百分比参考
✅代表基础可用 ❌代表基础不可用 x%代表完善度
- core 核心 ✅60%
- rendering 渲染 ✅35%
- resource 资源 ✅30%
- audio 音频 ✅70%
- input 输入 ✅40%
- collision 碰撞 ✅50%
- math 数学 ✅20%
- debug 调试 ✅40%
创建项目
使用mingmaker-cli
https://www.npmjs.com/package/mingmaker-cli-old
快速开始
import { boot, mmClass, Node, Text, Component, resources, ResourceType } from "mingmaker";
// 启动引擎
boot();
// 加载资源
resources.loadArr([
// 要加载的资源列表
]).then(() => {
console.log("资源加载完成");
initGame();
}).catch((e) => {
console.error("资源加载失败", e);
});
function initGame(): void {
// 创建节点
const node1 = Node.create("node1");
// 设置属性
node1.x = 0;
node1.y = 0;
// 添加组件
const text = node1.addComponent(Text);
// 设置组件属性
text.text = "Hello World";
// 声明组件
@mmClass("MyComponent")
class MyComponent extends Component {
onCreate() {
console.log("创建了组件 MyComponent");
}
}
// 添加 MyComponent 组件
node1.addComponent(MyComponent);
// ..
}
加载资源
// 加载资源示例
resources.loadArr([
// 图片资源
{ name: "test_image", type: ResourceType.IMAGE, src: "./img/test.png" },
// 音频资源
{ name: "test_audio", type: ResourceType.AUDIO, src: "./audio/test.mp3" },
// 骨骼动画资源
{ name: "test_spine", type: ResourceType.SPINE, src: ["./spine/test/test.json", "./spine/test/test.atlas"] }
]);
// 资源使用示例
// 设置精灵纹理
const texture = resources.get(ResourceType.IMAGE, "test_image");
sprite.texture = texture;
// 播放背景音乐
audioSystem.playMusic("test_audio", 1);
// 播放音效
audioSystem.playSound("test_audio", 1);
// 设置骨骼动画数据
spineComponent.spineDataName = "test_spine";
源码编译
dev 开发环境
- 启动编译 pnpm run dev
- 编译位置 ./build/dev/mm.js
prod 生产环境
生产环境编译需要同时开启了dev环境编译之后才能进行 不然会无法生成最新的.d.ts文件
- 启动编译 pnpm run build
- 编译位置 ./build/prod/mm.js
引擎使用到的开源库 非常感谢
- pixi.js
- sat.js
- matter-js
- howler.js
- stats.js
- @esotericsoftware/spine-pixi
以及使用到的开源库/工具 见package.json 非常感谢
联系方式
- 有任何问题或建议
- 对该项目感兴趣 或有一起开发维护的想法
- 欢迎联系我 email:2430877819@qq.com
- 或在github提交issue https://github.com/yxdtg/MingMaker/issues
计划
- 准备中..
0.1.110
11 months ago