var a =this.node;//获取当前脚本所在的节点var a =this.node.parent;//获取父节点var a =this.node.getChildByTag(1001);//通过标签获取子节点var node = cc.find("Canvas/bg");//通过访问路径来获取节点var a =this.node.getChildByName('name');//通过名字获取子节点var a =this.node.children;//获取所有子节点var a =this.node.childrenCount;//获取子节点数量var a = cc.director.getScene();//获取场景主节点var a = cc.instantiate(node);//克隆节点this.node.parent = cc.find('Canvas');//绑定父节点this.node.addChild(nodeName,zIndex,tag);//添加子节点,可设置层级和标签this.node.destroy();//销毁节点this.node.isValid;//判定节点是否可用this.node.removeChild(newNode);//移除节点中指定的子节点this.node.removeChildByTag(1001);//通过标签移除节点中指定的子节点this.node.removeAllChildren();//移除所有子节点this.node.destroyAllChildren();//销毁所有子节点this.node.cleanup();//停止所有正在播放的动作和计时器var sprites =this.node.getComponentsInChildren(cc.Label);//递归查找自身及所有子节点中指定类型的组件
//获得设备分辨率var b = cc.director.getWinSizeInPixels()var bx = b.width
var by = b.height
cc.view.getCanvasSize().width;//获得设备分辨率的宽度
cc.view.getCanvasSize().height;//获得设备分辨率的高度
cc.director.setDisplayStats(true);//显示帧数信息
常用用法1.场景加载2.获取节点3.获取节点位置,设置节点4.计时器5.事件监听6.定义全局变量7.分辨率8.音频控制9.存档操作10.判断平台11.监听和发射事件12.其他操作1.场景加载cc.director.loadScene('场景名称');//场景跳转cc.director.preloadScene('场景名称');//预加载场景cc.director.getScene();//获取当前场景2.获取节点var a = this.node;//获取当前脚本所在的节点var a = t