11# 在基于TypeScript的LayaAir HTML5游戏开发中使用AMD
22
33## AMD
4- AMD是"Asynchronous Module Definition"的缩写,意思就是"异步模块定义"。这是目前最流行的JavaScript/TypeScript代码的管理方式。本文介绍了如何在基于TypeScript的LayaAir HTML5游戏开发中使用AMD来组织代码。本文参考资料列表中包含了更多关于AMD的信息 。
4+ AMD是"Asynchronous Module Definition"的缩写,意思就是"异步模块定义"。这是目前最流行的JavaScript/TypeScript代码的管理方式。本文介绍了如何在基于TypeScript的LayaAir HTML5游戏开发中使用AMD来组织代码。本文末尾的参考资料列表中包含了更多关于AMD的信息 。
55
66## 示例项目
77示例项目源码从这里下载[ https://github.com/wildfirecode/HTML5-Game-AMD-TypeScript ] [ demo ] .
@@ -10,13 +10,13 @@ AMD是"Asynchronous Module Definition"的缩写,意思就是"异步模块定
1010依然使用LayaIDE来创建项目,因为要使用LayaAir引擎的库文件。
1111
1212## 使用Visual Studio Code作为编码调试环境
13- 为了能够对index.html有绝对的控制权,我们不能再使用LayaIDE,为了能够编译和调试项目 ,我们需要添加一些额外的配置。
13+ 为了能够对index.html有绝对的控制权,我们不能再使用LayaIDE来编译项目。另外,为了在VSCode中能够编译和调试项目 ,我们需要添加一些额外的配置。
1414- 复制示例项目中的` .vscode ` 文件夹到自己项目的根目录。
15- - 在index.html文件中引入所有的游戏代码编译文件
15+ - 在index.html文件中引入所有游戏代码的编译文件
1616 ``` html
1717 <script src =" ./js/game.js" ></script >
1818 ```
19- - 在index.html文件中启动游戏 。
19+ - 在index.html文件中实例化游戏入口类 。
2020 ```html
2121 <script >
2222 require ([' GameMain' ], function (GameMain ) {
@@ -28,7 +28,6 @@ AMD是"Asynchronous Module Definition"的缩写,意思就是"异步模块定
2828 ```ts
2929 export const EventDispatcher = Laya.EventDispatcher;
3030 ```
31-
3231- 使用示例项目中的`tsconfig.json`覆盖原来的`tsconfig.json`文件。
3332
3433## 编译和调试
@@ -50,4 +49,4 @@ AMD是"Asynchronous Module Definition"的缩写,意思就是"异步模块定
5049[js3]: http://www.ruanyifeng.com/blog/2012/11/require_js.html
5150[lib]: http://requirejs.org/docs/release/2.3.4/minified/require.js
5251[demo]: https://github.com/wildfirecode/HTML5-Game-AMD-TypeScript
53- [autoimport]: https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero
52+ [autoimport]: https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero
0 commit comments