Common methods seems to be missing or not working

Common methods seems to be missing or not working


I tried to use:


The method does not seems to work. I had to implement atan2 my self. Prety annoying.
Also I searched the entire API for a very basic method like: getDistance or distance between.

Did not find any of those except DistanceJoint which did not help too.

Did I missed somthing?

There is also a vmath lib which is not accessed at all duo to a missing vmath.d.ts file or somthing.

Tween still missed a lot of types in the creator.d.ts. I cannot do anything with the tween without toucing the creator file or by writing ts code like it is js code. Is it possible to fix it before the next update?

Get or set node size is strange. Was not very intuitive on my end. Had to setContentSize after creating a new node and not before it. Why is it not accessible like posision.x or rotation or scale.x or anchor?

Great web engine btw.
I hope to see the new material system soon…

What version of Creator are you using?

Latest… 2.0.10

By the way, tween class has a constructor that has a parameter of type node. However, you cannot instanciate a tween with parameter in ts and you cannot set target.

I am using version 2.0.10 and I also tried the 3d version 2.1.1.

I am writing my code using typescript.

Thanks for your feedback. 2.1.2 is ready for release, so the fixes will be 2.1.3.

vmath is an internal lib.

maybe mag is what you need?

Not very clear.
How to setContentSize with a not existing node?

Thanks a lot for your help!

Ok, so Vec2.mag is not good enough. I need a distance between two nodes or two vectors like this:

const node_one = new cc.Node("Node_1");
node_one.position.x = 10;
node_one.position.y = 10;

const node_two = new cc.Node("Node_2");
node_two .position.x = 59;
node_two .position.y = 60;

// example 1

// example 2
Vec2.distanceBetween(node_one.position, node_two.position);

// Problem with mag
const vector = new cc.Vec2(10, 10);
vector.mag(/* Maybe put a variable to match distance with? */);
// This is returning distance from constant point of 0, 0.

In 3D world it could be a little pain…

About the set content size:
I am creating new node and setup its size with setContentSize.
After that I am pushing this node to be a child of another node then it looks like the size I gave it is not correct. I need to setContentSize after I appendChild and not before.

Its not an issue by the way. Its how the engine works and its fine for me. It just could be more intuitive if it was work like in unity.

And how do I implement correctly lookAt?

// Following option not work:
const newNode = new cc.Node("new_node");
newNode .parent = this.node.parent;
newNode .position.x = 0;
newNode .position.y = 0;

const some_value_to_be_expected = this.node.lookAt(newNode);

Thanks again for your comment. Cant wait for next release…

Get it. I think we need a distance api for vec2, vec3.
For now, you can use mag like this:

node_one.position.sub(node_two .position).mag()

What effect do you want?

node.lookAt will return nothing. It just change the node’s rotation to point to the specified node.