码迷,mamicode.com
首页 > Windows程序 > 详细

cocos api

时间:2019-02-14 15:12:55      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:oar   多点   cocos   false   eve   移动   lse   计时器   getch   

$$$$$$$$$$$$$$$$
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 api

标签:oar   多点   cocos   false   eve   移动   lse   计时器   getch   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!