Giter VIP home page Giter VIP logo

cocos-utils's Introduction

cocos-utils

Cocos utilities for Cocos2d-html5 NPM supporting.

A tool to help developers coding cocos2d-html5 easily.

安装

  • 安装nodejs
  • 执行命令:
npm install cocos-utils -g

创建cocos2d-html5项目

cd到工程所要存放的目录下,例如想建工程名为HelloWorld的项目,执行以下命令:

cd the/dir/you/want/to/put/your/project/
cocos init HelloWorld

执行完命令之后,将会在当前文件夹生产一个名为HelloWorld的文件夹。

安装依赖包

按照npm规范,在package.json中添加dependencies。默认已经为开发者添加上了cocos2d-html5依赖。然后在工程根目录下执行:npm install

添加图片等资源文件

将图片资源放在res目录下,然后cdHelloWorld目录下,执行

cocos genRes

或者如果使用的ide是WebStorm,可以在tools文件夹中找到genRes.js,右击运行nodejs。

此时,在src/cfg/res.js中,将会生成资源路径的配置文件。注意:文件名要唯一,-在key中将会被_替换掉。

添加js代码

src中添加工程代码,test文件夹中添加工程测试代码。然后同上,执行

cocos genJsRes

或者右击运行tools/genJsRes.js

此时,在src/cfg/jsRes.js中,将会生成js的路径配置文件。生成的对象的命名规则为js.+项目名。注意:文件名要唯一,-在key中将会被_替换掉。

进行resCfg配置

此步骤在 https://github.com/SmallAiTT/ModuleDemo 中有详细介绍,就不重复写了。

修改main.js,运行工程。

同上。

发布

执行以下命令进行工程发布,规则通genRes:

cocos publish

或者右击运行tools/publish.js

  • 当前版本还未将混淆完全做好。

cocos-utils's People

Contributors

smallaitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.