用Typescript操作cc.Tween...

小弟是从Unity跳来的Creator新手,觉得Tween这个功能用起来比Action还要直观一点,
但范例实在不多,摸了半天还是搞不懂要怎么用…

直接上一段code

BtnClick(event : any, customEventData : any) : void
{
    var tween : cc.Tween = new cc.Tween();
    tween.tween(this.myPic.node);
    tween.to(2,{position : cc.v2(100,100)},{progress : myProgress,easing : cc.easeBackIn});
    tween.start();

}

这是我的一个按钮事件,很简单的操作,一张图飞到(100,100)的位置,
上面编辑器会直接跳错:
ERROR: Uncaught TypeError: tween.tween is not a function
但是文档里面明明就是function…

请问要怎么要写才是正确的呢?

求指点

1赞

2.09p1 的 cc.Tween Type definition 不全,错误提示是很正常的,估计官方会在下个版本补全吧

cc.tween(this.myPic.node).to(2, {position: cc.v2(100, 100)}).start();

原来如此,那我暂时还是先使用Action来操作好了,感谢

除了要引入

export function tween(target: any): Tween;

版本 Cocos Creator v2.1.2

具体缓动的选择 可以这样选择 好多 问题下面 没有写的那么详细,我经过摸索 搞定

第一个

this.node.scale = 0.5;
this.effectTween = cc.tween(this.node).to(0.3,{scaleX:1.0,scaleY:1.0},{progress:null,easing:cc.easing.backInOut}).start();

第二种

this.node.scale = 0.5;
this.effectTween = cc.tween(this.node).to(0.3,{scaleX:1.0,scaleY:1.0},{progress:null,easing:“backInOut”}).start();