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
add tween syntactic sugar #6327
add tween syntactic sugar #6327
Conversation
@@ -498,6 +500,10 @@ var Component = cc.Class({ | |||
}, | |||
|
|||
_onPreDestroy () { | |||
if (ActionManagerExist) { | |||
cc.director.getActionManager().removeAllActionsFromTarget(this); |
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.
节点已经在 _onPreDestroy 里停止 action 了。
我在考虑是不是需要在 CCObject 里面做,不过这样很多无关的也会去判断了。
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.
只有组件和节点才需要吧……
cocos2d/actions/tween.js
Outdated
*/ | ||
tintBy (duration, color, opts) { | ||
return this.by(duration, { color }, opts); | ||
} |
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.
flipX, Y,还有后面这些单行实现的封装感觉意义不大啊,他想要代码这么抽象的话自己封装一个小函数也行
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.
原 action 有的都可以有,已经有用户抱怨这些函数为什么没了
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.
这些都是对 node 的扩展,要不加个 tween-extends-node.js,做个单独的扩展模块?
核心 tween 仍然是很干净的
cocos2d/actions/tween.js
Outdated
* !#zh 按照贝塞尔路径设置目标的 position 属性。 | ||
* @method bezierTo | ||
* @param {number} duration | ||
* @param {[cc.Vec2, cc.Vec2, cc.Vec2]} controls |
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.
保持原有的接口。。
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.
那拆开吧
@@ -498,6 +500,10 @@ var Component = cc.Class({ | |||
}, | |||
|
|||
_onPreDestroy () { | |||
if (ActionManagerExist) { | |||
cc.director.getActionManager().removeAllActionsFromTarget(this); |
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.
只有组件和节点才需要吧……
cocos2d/actions/tween.js
Outdated
* !#zh 按照贝塞尔路径设置目标的 position 属性。 | ||
* @method bezierBy | ||
* @param {number} duration | ||
* @param {[cc.Vec2, cc.Vec2, cc.Vec2]} controls |
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.
这样写,d.ts能正常识别么,cc.Vec2[] 会不会好一点
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.
这么写是强制传 3 个 cc.Vec2 的 array, cc.Vec2[] 没有限制个数
… v2.3.3-release-tween # Conflicts: # cocos2d/actions/tween.js
… v2.3.3-release-tween
type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base]; | ||
type KeyPartial<T, K extends keyof T> = { [P in K]?: T[P] }; | ||
type OmitType<Base, Type> = KeyPartial<Base, AllowedNames<Base, Type>>; | ||
type ConstructorType<T> = OmitType<T, Function>; |
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.
ts就是这点不好,看不懂
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.
你仔细看下上面的链接就懂了,^_^
Re: cocos/2d-tasks#2604
Changes:
利用泛型完善了 tween 的代码提示机制
