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
fixed cc.RotateTo error #5717
fixed cc.RotateTo error #5717
Conversation
cocos2d/actions/CCActionInterval.js
Outdated
@@ -895,7 +895,7 @@ cc.RotateTo = cc.Class({ | |||
*/ | |||
initWithDuration:function (duration, dstAngle) { | |||
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) { | |||
this._dstAngle = dstAngle; | |||
this._dstAngle = -dstAngle; |
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.
为什么转成负的,就变成angle了呢
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.
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.
用户没有用rotation呀,他只设置了angle
node.angle=22;
node.runAction(cc.rotateTo(1.0, -22));
这跟rotation有什么关系么
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.
是的,和 rotation 没有关系,拿它说只是因为 CCNode 上还是用它来表示旋转角度。
这里之所以要 * -1,是因为 2.1 升级之后 angle 带来的改动。用户传入的 end_degree 需要 * -1 才能变成 angle,才能在 2.1 之后的版本中正确使用。
我改了之后试了下,表现结果是正确的。 |
不用改啊,让他设置 cc.macro.ROTATE_ACTION_CCW 来决定旋转方向是逆时针还是顺时针。 cc.macro.ROTATE_ACTION_CCW 的添加请参考 https://github.com/cocos-creator/2d-tasks/issues/1554 |
和设置顺逆时针没关系,用户反馈的是当前(默认顺时针)cc.RotatoTo(1, -22)执行之后,节点的角度表现不是 -22 该有的表现而是 22 的。所以是 rotateTo 有问题,而不是别的。 |
This reverts commit f831a18.
第一次的修改,从作用上是和开发者的思路一致的,也是取负转换,但是当时没有考虑到用户改变了转向之后会导致问题。cc.rotateBy 上也有类似处理,它采用的是:
考虑到目前 startWithTarget 现在的代码设计,我觉得直接修改在 startWithTarget 中,会更直接一点。 |
cocos2d/actions/CCActionInterval.js
Outdated
@@ -881,6 +881,7 @@ cc.RotateTo = cc.Class({ | |||
extends: cc.ActionInterval, | |||
|
|||
ctor:function (duration, dstAngle) { | |||
dstAngle *= cc.macro.ROTATE_ACTION_CCW ? 1 : -1; |
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.
不用加这句吧,你加了这句,下面这句不就又回到最开始的状态了么
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.
没有删掉。。。
issues: https://github.com/cocos-creator/2d-tasks/issues/2063
用户传入的是 rotation 的值,而引擎内部使用 rotation 进行旋转变换需要把 rotation 转成 angle 才能正确使用。
之前 cc.RotateTo 内部没有对用户传入的 rotation 转换成 angle。