mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
move globalZorder anchor to CCNode
This commit is contained in:
@@ -2115,6 +2115,139 @@ var Node = cc.Class({
|
||||
return this._opacityModifyRGB;
|
||||
},
|
||||
|
||||
/*
|
||||
* !#en
|
||||
* Defines the oder in which the nodes are renderer.
|
||||
* Nodes that have a Global Z Order lower, are renderer first.
|
||||
* <br/>
|
||||
* In case two or more nodes have the same Global Z Order, the oder is not guaranteed.
|
||||
* The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used.
|
||||
* <br/>
|
||||
* By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes.
|
||||
* <br/>
|
||||
* Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
|
||||
* <br/>
|
||||
* Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their ancestors.
|
||||
* And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.
|
||||
* !#zh
|
||||
* 定义节点的渲染顺序。
|
||||
* 节点具有全局 Z 顺序,顺序越小的节点,最先渲染。
|
||||
* </br>
|
||||
* 假设两个或者更多的节点拥有相同的全局 Z 顺序,那么渲染顺序无法保证。
|
||||
* 唯一的例外是如果节点的全局 Z 顺序为零,那么场景中的顺序是可以使用默认的。
|
||||
* </br>
|
||||
* 所有的节点全局 Z 顺序都是零。这就是说,默认使用场景中的顺序来渲染节点。
|
||||
* </br>
|
||||
* 全局 Z 顺序是非常有用的当你需要渲染节点按照不同的顺序而不是场景顺序。
|
||||
* </br>
|
||||
* 局限性: 全局 Z 顺序不能够被拥有继承 “SpriteBatchNode” 的节点使用。
|
||||
* 并且如果 “ClippingNode” 是其中之一的上代,那么 “global Z order” 将会和 “ClippingNode” 有关。
|
||||
* @method setGlobalZOrder
|
||||
* @param {Number} globalZOrder
|
||||
* @example
|
||||
* node.setGlobalZOrder(0);
|
||||
*/
|
||||
setGlobalZOrder: function (globalZOrder) {
|
||||
this._globalZOrder = globalZOrder;
|
||||
this._sgNode.setGlobalZOrder(globalZOrder);
|
||||
},
|
||||
|
||||
/*
|
||||
* !#en Return the Node's Global Z Order.
|
||||
* !#zh 获取节点的全局 Z 顺序。
|
||||
* @method getGlobalZOrder
|
||||
* @returns {number} The node's global Z order
|
||||
* @example
|
||||
* cc.log("Global Z Order: " + node.getGlobalZOrder());
|
||||
*/
|
||||
getGlobalZOrder: function () {
|
||||
this._globalZOrder = this._sgNode.getGlobalZOrder();
|
||||
return this._globalZOrder;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Returns a copy of the anchor point.<br/>
|
||||
* Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
|
||||
* It's like a pin in the node where it is "attached" to its parent. <br/>
|
||||
* The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
|
||||
* But you can use values higher than (1,1) and lower than (0,0) too. <br/>
|
||||
* The default anchor point is (0.5,0.5), so it starts at the center of the node.
|
||||
* !#zh
|
||||
* 获取节点锚点,用百分比表示。<br/>
|
||||
* 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
|
||||
* 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
|
||||
* 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
|
||||
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
|
||||
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
|
||||
* @method getAnchorPoint
|
||||
* @return {Vec2} The anchor point of node.
|
||||
* @example
|
||||
* cc.log("Node AnchorPoint: " + node.getAnchorPoint());
|
||||
*/
|
||||
getAnchorPoint: function () {
|
||||
return cc.p(this._anchorPoint);
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Sets the anchor point in percent. <br/>
|
||||
* anchor point is the point around which all transformations and positioning manipulations take place. <br/>
|
||||
* It's like a pin in the node where it is "attached" to its parent. <br/>
|
||||
* The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
|
||||
* But you can use values higher than (1,1) and lower than (0,0) too.<br/>
|
||||
* The default anchor point is (0.5,0.5), so it starts at the center of the node.
|
||||
* !#zh
|
||||
* 设置锚点的百分比。<br/>
|
||||
* 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
|
||||
* 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
|
||||
* 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
|
||||
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
|
||||
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
|
||||
* @method setAnchorPoint
|
||||
* @param {Vec2|Number} point - The anchor point of node or The x axis anchor of node.
|
||||
* @param {Number} [y] - The y axis anchor of node.
|
||||
* @example
|
||||
* node.setAnchorPoint(cc.v2(1, 1));
|
||||
* node.setAnchorPoint(1, 1);
|
||||
*/
|
||||
setAnchorPoint: function (point, y) {
|
||||
var locAnchorPoint = this._anchorPoint;
|
||||
if (y === undefined) {
|
||||
if ((point.x === locAnchorPoint.x) && (point.y === locAnchorPoint.y))
|
||||
return;
|
||||
locAnchorPoint.x = point.x;
|
||||
locAnchorPoint.y = point.y;
|
||||
} else {
|
||||
if ((point === locAnchorPoint.x) && (y === locAnchorPoint.y))
|
||||
return;
|
||||
locAnchorPoint.x = point;
|
||||
locAnchorPoint.y = y;
|
||||
}
|
||||
var sizeProvider = this._sizeProvider;
|
||||
if (sizeProvider instanceof _ccsg.Node) {
|
||||
sizeProvider.setAnchorPoint(locAnchorPoint);
|
||||
}
|
||||
this.emit(ANCHOR_CHANGED);
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Returns a copy of the anchor point in absolute pixels. <br/>
|
||||
* you can only read it. If you wish to modify it, use setAnchorPoint.
|
||||
* !#zh
|
||||
* 返回锚点的绝对像素位置。<br/>
|
||||
* 你只能读它。如果您要修改它,使用 setAnchorPoint。
|
||||
* @see cc.Node#getAnchorPoint
|
||||
* @method getAnchorPointInPoints
|
||||
* @return {Vec2} The anchor point in absolute pixels.
|
||||
* @example
|
||||
* cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
|
||||
*/
|
||||
getAnchorPointInPoints: function () {
|
||||
return this._sgNode.getAnchorPointInPoints();
|
||||
},
|
||||
|
||||
//functions moved from base node end
|
||||
|
||||
});
|
||||
|
||||
@@ -367,139 +367,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* !#en
|
||||
* Defines the oder in which the nodes are renderer.
|
||||
* Nodes that have a Global Z Order lower, are renderer first.
|
||||
* <br/>
|
||||
* In case two or more nodes have the same Global Z Order, the oder is not guaranteed.
|
||||
* The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used.
|
||||
* <br/>
|
||||
* By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes.
|
||||
* <br/>
|
||||
* Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
|
||||
* <br/>
|
||||
* Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their ancestors.
|
||||
* And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.
|
||||
* !#zh
|
||||
* 定义节点的渲染顺序。
|
||||
* 节点具有全局 Z 顺序,顺序越小的节点,最先渲染。
|
||||
* </br>
|
||||
* 假设两个或者更多的节点拥有相同的全局 Z 顺序,那么渲染顺序无法保证。
|
||||
* 唯一的例外是如果节点的全局 Z 顺序为零,那么场景中的顺序是可以使用默认的。
|
||||
* </br>
|
||||
* 所有的节点全局 Z 顺序都是零。这就是说,默认使用场景中的顺序来渲染节点。
|
||||
* </br>
|
||||
* 全局 Z 顺序是非常有用的当你需要渲染节点按照不同的顺序而不是场景顺序。
|
||||
* </br>
|
||||
* 局限性: 全局 Z 顺序不能够被拥有继承 “SpriteBatchNode” 的节点使用。
|
||||
* 并且如果 “ClippingNode” 是其中之一的上代,那么 “global Z order” 将会和 “ClippingNode” 有关。
|
||||
* @method setGlobalZOrder
|
||||
* @param {Number} globalZOrder
|
||||
* @example
|
||||
* node.setGlobalZOrder(0);
|
||||
*/
|
||||
setGlobalZOrder: function (globalZOrder) {
|
||||
this._globalZOrder = globalZOrder;
|
||||
this._sgNode.setGlobalZOrder(globalZOrder);
|
||||
},
|
||||
|
||||
/*
|
||||
* !#en Return the Node's Global Z Order.
|
||||
* !#zh 获取节点的全局 Z 顺序。
|
||||
* @method getGlobalZOrder
|
||||
* @returns {number} The node's global Z order
|
||||
* @example
|
||||
* cc.log("Global Z Order: " + node.getGlobalZOrder());
|
||||
*/
|
||||
getGlobalZOrder: function () {
|
||||
this._globalZOrder = this._sgNode.getGlobalZOrder();
|
||||
return this._globalZOrder;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Returns a copy of the anchor point.<br/>
|
||||
* Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
|
||||
* It's like a pin in the node where it is "attached" to its parent. <br/>
|
||||
* The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
|
||||
* But you can use values higher than (1,1) and lower than (0,0) too. <br/>
|
||||
* The default anchor point is (0.5,0.5), so it starts at the center of the node.
|
||||
* !#zh
|
||||
* 获取节点锚点,用百分比表示。<br/>
|
||||
* 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
|
||||
* 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
|
||||
* 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
|
||||
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
|
||||
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
|
||||
* @method getAnchorPoint
|
||||
* @return {Vec2} The anchor point of node.
|
||||
* @example
|
||||
* cc.log("Node AnchorPoint: " + node.getAnchorPoint());
|
||||
*/
|
||||
getAnchorPoint: function () {
|
||||
return cc.p(this._anchorPoint);
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Sets the anchor point in percent. <br/>
|
||||
* anchor point is the point around which all transformations and positioning manipulations take place. <br/>
|
||||
* It's like a pin in the node where it is "attached" to its parent. <br/>
|
||||
* The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
|
||||
* But you can use values higher than (1,1) and lower than (0,0) too.<br/>
|
||||
* The default anchor point is (0.5,0.5), so it starts at the center of the node.
|
||||
* !#zh
|
||||
* 设置锚点的百分比。<br/>
|
||||
* 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
|
||||
* 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
|
||||
* 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
|
||||
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
|
||||
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
|
||||
* @method setAnchorPoint
|
||||
* @param {Vec2|Number} point - The anchor point of node or The x axis anchor of node.
|
||||
* @param {Number} [y] - The y axis anchor of node.
|
||||
* @example
|
||||
* node.setAnchorPoint(cc.v2(1, 1));
|
||||
* node.setAnchorPoint(1, 1);
|
||||
*/
|
||||
setAnchorPoint: function (point, y) {
|
||||
var locAnchorPoint = this._anchorPoint;
|
||||
if (y === undefined) {
|
||||
if ((point.x === locAnchorPoint.x) && (point.y === locAnchorPoint.y))
|
||||
return;
|
||||
locAnchorPoint.x = point.x;
|
||||
locAnchorPoint.y = point.y;
|
||||
} else {
|
||||
if ((point === locAnchorPoint.x) && (y === locAnchorPoint.y))
|
||||
return;
|
||||
locAnchorPoint.x = point;
|
||||
locAnchorPoint.y = y;
|
||||
}
|
||||
var sizeProvider = this._sizeProvider;
|
||||
if (sizeProvider instanceof _ccsg.Node) {
|
||||
sizeProvider.setAnchorPoint(locAnchorPoint);
|
||||
}
|
||||
this.emit(ANCHOR_CHANGED);
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Returns a copy of the anchor point in absolute pixels. <br/>
|
||||
* you can only read it. If you wish to modify it, use setAnchorPoint.
|
||||
* !#zh
|
||||
* 返回锚点的绝对像素位置。<br/>
|
||||
* 你只能读它。如果您要修改它,使用 setAnchorPoint。
|
||||
* @see cc.Node#getAnchorPoint
|
||||
* @method getAnchorPointInPoints
|
||||
* @return {Vec2} The anchor point in absolute pixels.
|
||||
* @example
|
||||
* cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
|
||||
*/
|
||||
getAnchorPointInPoints: function () {
|
||||
return this._sgNode.getAnchorPointInPoints();
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Returns a copy the untransformed size of the node. <br/>
|
||||
|
||||
Reference in New Issue
Block a user