Cc.v3 in new creator 2.1.0 and cc.v2 do not work well together!

Cc.v3 in new creator 2.1.0 and cc.v2 do not work well together!
0

#1

With the new render system preparing for 3D games in future (i think so), the node.position now return cc.v3 object instead of cc.v2 and my troubles come from here.

Let’s say that i’ve 2 nodes and i’d like to calculate distance between them to make motion effect (Ex: earned coin move from enemy to UI), and these 2 nodes stay in different containers () and i do as below:

  1. Convert enemy position from its container to coin’s container by convertToNodeSpaceAR function and this return cc.v2 same as older cocos version. (called enemyPos)
  2. Get coin’s position by call node.position and this return cc.v3 object instead of cc.v2 object as older cocos version. (called coinPos)
  3. Now calling coinPos.sub(enemyPos).mag() return NaN value and things go wrong!!!

I can handle this trouble by doing a simple convert cc.v2<=>cc.v3 but it’s not sense and so so conflict. Where return cc.v2? Where return cc.v3? Which functions these 2 objects work together? How many conflict APIs between 2D and 3D functions stays there? I’ve a little bit of worry!!!


#2

http://docs.cocos2d-x.org/creator/2.1/manual/en/3d/3d-node.html
Read this it should help


#3

at the document choose Version2.1 to check 3d’s api and tips
image

http://docs.cocos2d-x.org/creator/2.1/manual/en/3d/


#4

It does not help too much, the problem stay in function convertToNodeSpaceAR. It return cc.v2 object while Node.position return cc.v3 object. I think it’s better if cc.v2 is deprecated, it’s just cc.v3(x, y, 0).