cocos

生命周期回调
onLoad
start
update
lateUpdate
onDestroy
onEnable
onDisable

http://www.uc129.com/  红警之家


http://docs.cocos.com/creator/manual/zh/scripting/reference/class.html#type-%E5%8F%82%E6%95%B0
属性常用参数:
default:设置属性的默认值,这个默认值仅在组件第一次添加到节点上时才会用到
type:限定属性的数据类型,详见 CCClass 进阶参考:type 参数

Label、AudioClip、Prefab、Node、Vec2、spritrFrame(精灵帧)
Integer、Boolean、String、Float、

visible:设为 false 则不在属性检查器面板中显示该属性
serializable: 设为 false 则不序列化(保存)该属性
displayName:在属性检查器面板中显示成指定名字
tooltip:在属性检查器面板中添加属性的 tooltip


 API

$$$$$$$$$$$$$$$$
cc.p() <=> x,y

$$$$$$$$$$$$$$$$
场景间的跳转
$$$$$$$$$$$$$$$$
cc.director.loadScene('场景名称') -- game.fire
cc.director.preloadScene('场景名称') -- game.fire

$$$$$$$$$$$$$$$$
计时器
$$$$$$$$$$$$$$$$
this.schedule(function(){},秒)
component.schedule(function(){
this.doSomething();s
},5,3,10) //计时器,重复间隔,重复次数,延时
scheduleOnce()
unschedule()

$$$$$$$$$$$$$$$$
prefab(预制)
$$$$$$$$$$$$$$$$
cc.random0To1() //0~1
cc.instantiate(node) //克隆节点


$$$$$$$$$$$$$$$$
事件
$$$$$$$$$$$$$$$$
cc.KEY.a
cc.macro.KEY.a
event.getLocation().x
cc.winSize.width/2
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
####
cocosCreator 键盘四方向移动(https://blog.csdn.net/wlinyi/article/details/52198023)
####
cc.Canvas.instance.node.on('touchstart/touchend', this.onTouchStart, this);

cc.eventManager.addListener(listener,nodeOrPriority) --将事件监听器添加到事件管理器中

cc.EventListener.KEYBOARD(鼠标输入事件)

cc.EventListener.MOUSE(鼠标)

cc.EventListener.TOUCH_ONE_BY_ONE(单点触摸)

cc.EventListener.TOUCH_ALL_AT_ONCE(多点触摸)


$$$$$$$$$$$$$$$$
节点
http://docs.cocos.com/creator/api/zh/classes/Node.html(Node)
http://docs.cocos.com/creator/api/zh/classes/Component.html(Component)
$$$$$$$$$$$$$$$$
new cc.Node('button')
cc.Node('button').addChild()
node.addComponent(cc.Sprite)
cc.instantiate(node) //克隆节点

this.node.active = false
this.node
this.node.parent

this.node.addChild
this.node.childrenCount
this.node.children
this.node.getChildByName("Cannon 01");
cc.find("Cannon 01/Barrel/SFX", this.node); cc.find("Cannon01/Barrel/SFX");


位置
this.node.x/this.node.y
this.node.setPosition(100, 50)
this.node.setPosition(cc.v2(100, 50))
this.node.position = cc.v2(100, 50)


this.node.on(事件,function(){}) -- mousedown
this.node.position.sub().mag()
this.node.destroy() -- removeFromParent()

this.getComponent(cc.Label); -- this.getComponent('star');


组件js与图层少了dom操作,用脱拽替换


网站资源
cocos
os

http://docs.cocos.com/creator/manual/zh/getting-started/quick-start.html
api
http://docs.cocos.com/creator/api/zh/
// Learn cc.Class:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html

原文地址:https://www.cnblogs.com/lgyong/p/9634764.html