cocos 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(鼠标)

扫描二维码关注公众号,回复: 5167821 查看本文章

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操作,用脱拽替换

猜你喜欢

转载自www.cnblogs.com/lgyong/p/9636416.html
今日推荐