Heim  >  Artikel  >  Web-Frontend  >  Egret引擎开发指南之运行项目_node.js

Egret引擎开发指南之运行项目_node.js

WBOY
WBOYOriginal
2016-05-16 16:37:451818Durchsuche

这是一个令人兴奋的小结,因为在这个小结中你终于能够看到你的第一个Demo的运行效果。

1.使用Egret工具运行游戏

运行Egret项目,我们需要一个已运行的HTTP服务器。在前面安装Egret的教程中,我们已经为大家推荐了一款HTTP服务器。现在我们来看一下如何使用我们egret提供的最简单的HTTP服务器来运行我们的项目。

和前面的教程一样,我们首相在终端中定位我们的项目,使用<font face="NSimsun">cd</font>命令。

然后我们执行一个简单的命令来启动Egret的HTTP服务器,命令如下:

<font face="NSimsun">egret startserver HelloWorld</font>

这个命令中<font face="NSimsun">egret startserver</font>为启动egret内部服务器的命令,而后面的<font face="NSimsun">HelloWorld</font>则是我们的项目名称。

当命令运行后,你会看到如图中的效果。

随后,egret工具会启动你的浏览器,启动的浏览器为当前操作系统的默认浏览器。egret工具启动Chrome后,会打开指定的网页,默认网页为http://localhost:3000/HelloWorld/launcher/index.html

此时你会在Chrome中看到一个带有简单动画的Hello World效果,效果如下图:

这里我们简单对服务器地址进行以下是说明,默认提供的服务器地址为<font face="NSimsun">http://localhost:3000/HelloWorld/launcher/index.html</font>。egret为我们启动的HTTP服务器访问地址为<font face="NSimsun">http://localhost:3000/</font>,其中<font face="NSimsun">http://localhost</font>为本机访问地址,<font face="NSimsun">3000</font>为我们使用的端口号,egret默认使用的端口号为“3000”。请确保在启动服务器之前,3000端口为未使用状态。

2.使用第三方HTTP服务器工具运行游戏

如果你安装了其他HTTP工具,那么现在你可以将其打开并运行

将游戏项目中的<font face="NSimsun">bin-debug</font><font face="NSimsun">launcher</font><font face="NSimsun">resources</font>文件夹拷贝到HTTP服务器的根目录或同级目录下。访问你的服务器地址即可运行游戏。

访问地址规则为 <font face="NSimsun">http://你的服务器地址/launcher/index.html</font>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn