Skip to content
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

fix CCMotionStreak err for fireball/issues/5881 #1727

Merged
merged 1 commit into from Jun 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions cocos2d/motion-streak/CCMotionStreak.js
Expand Up @@ -264,9 +264,18 @@ var MotionStreak = cc.Class({
sgNode.addChild(this._root, -10);
}
this._motionStreak = motionStreak;

},

onEnable: function () {
this.node.on('position-changed', this._onNodePositionChanged, this);
},

onDisable: function () {
this.node.off('position-changed', this._onNodePositionChanged, this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个事件只能监听到 node 本身的位移,监听不到父节点的位移,恐怕会有 bug 吧?

},

lateUpdate: function (delta) {
_onNodePositionChanged: function () {
if (CC_EDITOR && !this.preview) {
return;
}
Expand All @@ -279,7 +288,6 @@ var MotionStreak = cc.Class({
var ty = worldMt.ty - (node.height / 2 + node.anchorY * node.height);
this._root.setPosition(-tx, -ty);
this._motionStreak.setPosition(tx, ty);
this._motionStreak.update(delta);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把 update 函数调用去掉了不会有问题么。。。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没问题,因为 update 会被执行

}
}
});
Expand Down