cocos CC.Node详解

在这里插入图片描述

		/** !#en
		Group index of node.<br/>
		Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
		!#zh
		节点的分组索引。<br/>
		节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
		groupIndex: number;		
		/** !#en
		Group of node.<br/>
		Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
		!#zh
		节点的分组。<br/>
		节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
		group: string;		
		/** !#en The position (x, y) of the node in its parent's coordinates.
		!#zh 节点在父节点坐标系中的位置(x, y)。 */
		position: Vec3;		
		/** !#en x axis position of node.
		!#zh 节点 X 轴坐标。 */
		x: number;		
		/** !#en y axis position of node.
		!#zh 节点 Y 轴坐标。 */
		y: number;		
		/** !#en z axis position of node.
		!#zh 节点 Z 轴坐标。 */
		z: number;		
		/** !#en Rotation of node.
		!#zh 该节点旋转角度。 */
		rotation: number;		
		/** !#en
		Angle of node, the positive value is anti-clockwise direction.
		!#zh
		该节点的旋转角度,正值为逆时针方向。 */
		angle: number;		
		/** !#en The rotation as Euler angles in degrees, used in 3D node.
		!#zh 该节点的欧拉角度,用于 3D 节点。 */
		eulerAngles: Vec3;		
		/** !#en Rotation on x axis.
		!#zh 该节点 X 轴旋转角度。 */
		rotationX: number;		
		/** !#en Rotation on y axis.
		!#zh 该节点 Y 轴旋转角度。 */
		rotationY: number;		
		/** !#en The local scale relative to the parent.
		!#zh 节点相对父节点的缩放。 */
		scale: number;		
		/** !#en Scale on x axis.
		!#zh 节点 X 轴缩放。 */
		scaleX: number;		
		/** !#en Scale on y axis.
		!#zh 节点 Y 轴缩放。 */
		scaleY: number;		
		/** !#en Scale on z axis.
		!#zh 节点 Z 轴缩放。 */
		scaleZ: number;		
		/** !#en Skew x
		!#zh 该节点 X 轴倾斜角度。 */
		skewX: number;		
		/** !#en Skew y
		!#zh 该节点 Y 轴倾斜角度。 */
		skewY: number;		
		/** !#en Opacity of node, default value is 255.
		!#zh 节点透明度,默认值为 255。 */
		opacity: number;		
		/** !#en Color of node, default value is white: (255, 255, 255).
		!#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
		color: Color;		
		/** !#en Anchor point's position on x axis.
		!#zh 节点 X 轴锚点位置。 */
		anchorX: number;		
		/** !#en Anchor point's position on y axis.
		!#zh 节点 Y 轴锚点位置。 */
		anchorY: number;		
		/** !#en Width of node.
		!#zh 节点宽度。 */
		width: number;		
		/** !#en Height of node.
		!#zh 节点高度。 */
		height: number;		
		/** !#en zIndex is the 'key' used to sort the node relative to its siblings.<br/>
		The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.<br/>
		The Node's parent will sort all its children based on the zIndex value and the arrival order.<br/>
		Nodes with greater zIndex will be sorted after nodes with smaller zIndex.<br/>
		If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.<br/>
		Node's order in children list will affect its rendering order. Parent is always rendering before all children.
		!#zh zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。<br/>
		zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间
		父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。<br/>
		节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */
		zIndex: number;		
		/** !#en
		Switch 2D/3D node. The 2D nodes will run faster.
		!#zh
		切换 2D/3D 节点,2D 节点会有更高的运行效率 */
		is3DNode: boolean;		
		/** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space.
		!#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
		up: Vec3;		
		/** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space.
		!#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
		right: Vec3;		
		/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
		!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
		forward: Vec3;		
		/**
		
		@param name name 
		*/
		constructor(name?: string);		
		/**
		!#en
		Register a callback of a specific event type on Node.<br/>
		Use this method to register touch or mouse event permit propagation based on scene graph,<br/>
		These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:<br/>
		1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target<br/>
		2. At target phase: dispatch to the listeners of the real target<br/>
		3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root<br/>
		In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.<br/>
		It's the recommended way to register touch/mouse event for Node,<br/>
		please do not use cc.eventManager directly for Node.<br/>
		You can also register custom event and use `emit` to trigger custom event on Node.<br/>
		For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.<br/>
		You can also pass event callback parameters with `emit` by passing parameters after `type`.
		!#zh
		在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
		鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:<br/>
		1. 捕获阶段:派发事件给捕获目标(通过 `_getCapturingTargets` 获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。<br/>
		2. 目标阶段:派发给目标节点的监听器。<br/>
		3. 冒泡阶段:派发事件给冒泡目标(通过 `_getBubblingTargets` 获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。<br/>
		同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
		推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。<br/>
		你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器<br/>
		你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表
		@param type A string representing the event type to listen for.<br>See {
   {#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{
   {/crossLink}} for all builtin events.
		@param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
		@param target The target (this object) to invoke the callback, can be null
		@param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
		
		@example 
		```js
		this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this);  // if "this" is component and the "memberFunction" declared in CCClass.
		node.on(cc.Node.EventType.TOUCH_START, callback, this);
		node.on(cc.Node.EventType.TOUCH_MOVE, callback, this);
		node.on(cc.Node.EventType.TOUCH_END, callback, this);
		node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this);
		node.on(cc.Node.EventType.ANCHOR_CHANGED, callback);
		node.on(cc.Node.EventType.COLOR_CHANGED, callback);
		```
		*/</
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值