欢迎光临散文网 会员登陆 & 注册

Cocos Creator零基础小白超神教程

2023-07-29 10:44 作者:ZUQAQ  | 我要投稿

学到38p了

贡献一下笔记

/*

获得子节点:

this.node.Children[0];

this.node.getChidrenByName("abc");

cc.find("canvas/main camare")

*/

//--------------------------------------

/*

获取父节点:

this.node.getParent();

this.node.setParent(ddd); 设ddd为父节点

 */


//this.node.removeAllChildren(); 移除所有子节点

//this.node.removeChild(ddd); 移除名为ddd的子节点

//this.node.removeFromParent(); 把自己从父节点移除


/*

访问节点属性

this.node.x

this.node.setPosition(3,4);

this.node.setPosition(cc.v2(3,4));

this.node.rotation 旋转

this.node.scale 缩放

this.node.anchor 中心点位置

this.node.color = cc.Color.RED !赋值为枚举的颜色

 */

 

//this.node.active = true; false为关闭节点


/*

获取组件的属性: !!先let一个变量,值为属性,进行调用

this.getComponent(cc.Sprite); Sprite是cc的一个方法,获取自己的Sprite节点

Sprite.enabled = false 关闭组件

this.getComponentInChildren(cc.Sprite); 获取子节点的Sprite组件

 */


/*

预设体的使用:

@property(cc.Prefab)

prefab1:cc.Prefab = null   创建一个属性来放置预设体

、、

let yushe1 = cc.instantiate(this.prefab1) 实体化预设体并设为变量 !!要设置父节点

yushe1.setparent(this.node); 设置父节点

yushe1.setPosition(0,0); 设置位置

 */


/*

创建节点

let node1 = new cc.Node('Name')

node1.addComponent(cc.Sprite); 添加组件

*/


/*

场景:

cc.director.LoadScene("New Scene",function(){}) 切换场景,加载结束后执行函数,函数可不要

cc.director.preLoadScene("New Scene",function(){}) 预加载场景到内存,不显示场景,需要上一行代码进行显示,函数可作为加载的进度条。

 */

Cocos Creator零基础小白超神教程的评论 (共 条)

分享到微博请遵守国家法律