jamesalone jamesalone - 3 months ago 30
Javascript Question

Cocos2D JS Vec2 is undefined

I've been trying to use Vec2 for a while with no luck, I got error message such as Vec2 is undefined, Vec2 is not a function, etc.

Code I've tried:

var point = Vec2(100,100);

var point = cc.math.Vec2(100,100);

Is there anything else I'm missing? It seems that the documentation for Cocos2D JS is not up to date.


I have never used Vec2 in js so I do not know explicitly what is happening with that but you can use cc.p(x,y)


var point = cc.p(100, 100); cc.log(point.x) -> 100