-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't change z value when invoke setPosition or setScale with two parameter #7104
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0b81d3b
修改setPosition的默认行为.
finscn 952fcf5
修改setScale的行为, 不强制改变z值
finscn e303f62
修正前面讨论的一些问题, 同时统一了变量命名风格
finscn 8423a3f
更新注释
finscn a53f20f
Update CCNode.js
finscn a39edd1
Update CCNode.js
finscn 2a360ce
用同样的代码风格和思路 来处理 setPosition 和 setScale.
finscn 5e95d53
恢复被误删除的代码
finscn 403a44f
参考
finscn cfb347b
Update CCNode.js
finscn 92c52cb
cosmetic
finscn 30e44d2
Update CCNode.js
finscn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2690,8 +2690,8 @@ let NodeDefines = { | |
* !#zh | ||
* 设置节点在父节点坐标系中的位置。<br/> | ||
* 可以通过下面的方式设置坐标点:<br/> | ||
* 1. 传入 2 个数值 x, y。<br/> | ||
* 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。 | ||
* 1. 传入 2 个数值 x, y (此时不会改变position的z值)。<br/> | ||
* 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象 (此时不会改变position的z值)。 | ||
* 3. 对于 3D 节点可以传入 3 个数值 x, y, z。<br/> | ||
* 4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 | ||
* @method setPosition | ||
|
@@ -2704,14 +2704,18 @@ let NodeDefines = { | |
if (y === undefined) { | ||
x = newPosOrX.x; | ||
y = newPosOrX.y; | ||
z = newPosOrX.z || 0; | ||
z = newPosOrX.z; | ||
jareguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
else { | ||
x = newPosOrX; | ||
z = z || 0 | ||
} | ||
|
||
let trs = this._trs; | ||
|
||
if (z === undefined) { | ||
z = trs[2]; | ||
} | ||
jareguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (trs[0] === x && trs[1] === y && trs[2] === z) { | ||
return; | ||
} | ||
|
@@ -2765,6 +2769,7 @@ let NodeDefines = { | |
* !#zh | ||
* 设置节点在本地坐标系中坐标轴上的缩放比例。 | ||
* 2D 节点可以操作两个坐标轴,而 3D 节点可以操作三个坐标轴。 | ||
* 当只传入 (x, y) 或 Vec2对象时, 不会改变 scale.z 的值. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里注释也应该调整,vec2 会改变 scale z |
||
* @method setScale | ||
* @param {Number|Vec2|Vec3} x - scaleX or scale object | ||
* @param {Number} [y] | ||
|
@@ -2776,18 +2781,21 @@ let NodeDefines = { | |
*/ | ||
setScale (x, y, z) { | ||
if (x && typeof x !== 'number') { | ||
y = x.y; | ||
z = x.z === undefined ? 1 : x.z; | ||
x = x.x; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里代码执行顺序不可更改,改完之后 x 变成了 number,再获取 x.y 就报错了 |
||
y = x.y; | ||
z = x.z; | ||
} | ||
else if (x !== undefined && y === undefined) { | ||
y = x; | ||
z = x; | ||
} | ||
else if (z === undefined) { | ||
z = 1; | ||
} | ||
|
||
let trs = this._trs; | ||
|
||
if (z === undefined) { | ||
z = trs[9]; | ||
} | ||
|
||
if (trs[7] !== x || trs[8] !== y || trs[9] !== z) { | ||
trs[7] = x; | ||
trs[8] = y; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此时 z 会被重置为 0,麻烦更正一下注释。另外中文和英文之间插入个空格