關於Tween的問題

我用TypeScript 去寫
new cc.Tween(this.node)
.to(5,{position:pos,progress:(start,end,current,ratio)=>
{
return start + (end-start)*ratio;
},easing:“quadIn”})
.start();

可是會跳這些訊息
tween.js:39 Can not animate position property, because it do not have [lerp, (add|mul), clone] function.
ctor @ tween.js:39
tween.js:39 Can not animate progress property, because it do not have [lerp, (add|mul), clone] function.
ctor @ tween.js:39
tween.js:39 Can not animate easing property, because it do not have [lerp, (add|mul), clone] function.
ctor @ tween.js:39
可以幫我看一下 問題出在哪嗎??

提供下完整的demo,我们看看

test.zip (819.9 KB)

很單純的start的時候讀一個json 進來 然後執行tween
CocosCreator 版本是2.1.2

你传入的 pos:cc.Vec3 并不是 cc.Vec3 , 而是 {x,y,y} 这样对象,所以报警告了。

可是我改成傳new cc.Vec3(x,y,z)
還是會跳以下訊息
tween.js:39 Can not animate progress property, because it do not have [lerp, (add|mul), clone] function.
ctor @ tween.js:39
tween.js:39 Can not animate easing property, because it do not have [lerp, (add|mul), clone] function.
這有什麼方法可以解決嗎?

参考API文档
https://docs.cocos.com/creator/api/zh/classes/Tween.html#to

代码修改成这样

doLocalPath( pos:cc.Vec3 ):cc.Tween
{
pos = new cc.Vec3(pos.x,pos.y,pos.z);
new cc.Tween(this.node)
.to(5,{position:pos },{progress:(start,end,current,ratio)=>
{
return start + (end-start)*ratio;
},easing:“quadIn”})
.start();
}

問題已解決
改成這樣就可以了:+1: