Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
Currently, if we tween the custom type MyVec2 like the following.
class MyVec2 {
constructor(x = 0, y = 0) {
this.x = x;
this.y = y;
}
x = 0;
y = 0;
}
class MyTarget {
pos = new MyVec2();
}
const target = new MyTarget();
tween(target).to(1, { pos: new MyVec2(100, 100) }).start();
......
// run 60 frames
// target.pos will be `{ x: 100, y: 100}` which is a plain object , but it should be an instance of `MyVec2` of which type should not be changed.
Currently, if we tween the custom type
MyVec2
like the following.