一直想学会这个,这两天还算有空,来弄一下。
跟着中文官网走,主要以 js
开发
下载安装,
搭建环境网站都有说明
一开始我并没有安装
android jdk
之类的东东,只装了一个Python
,因为我只打算先弄web
端,后来编译不出来,于是干脆全部装上,于是就成功了。
第一个实例
当然hello world
就不说了,跟着官网走,有一个实例教程
一些基本命令
参照官网
创建项目
cocos new projectname
参数 | 含义 | 可能的值 | 示例 |
---|---|---|---|
l | 语言 | js | cocos new projectname -l js |
运行项目
cocos run -p web
编译项目
cocos compile -p web -m release
cocos2dx-js
创建一个label
var label = new cc.LabelTTF('Hello World!');
参数:
1. {String} text
2. {String|cc.FontDefinition} fontName Optional, Default: “Arial”
3. {Number} fontSize Optional, Default: 16
4. {cc.Size} dimensions Optional, Default: cc.size(0,0)
5. {Number} hAlignment Optional, Default: cc.TEXT_ALIGNMENT_LEFT
6. {Number} vAlignment Optional, Default: cc.VERTICAL_TEXT_ALIGNMENT_TOP
定时器
schedule(callback, interval, repeat, delay, key)
Schedules a custom selector.
If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
Parameters:
{function} callback
A function wrapped as a selector
{Number} interval
Tick interval in seconds. 0 means tick every frame. If interval = 0, it’s recommended to use scheduleUpdate() instead.
{Number} repeat
The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely.
{Number} delay
The amount of time that the first tick will wait before execution.
{String} key
The only string identifying the callback
写了一会发现我懒得再写了,哈哈,以后再写好了