求助 cc.pMult , cc.pAdd现在要用什么代替

求助 cc.pMult , cc.pAdd现在要用什么代替

看官方的API的文档

新建工程,查看根目录下creator.d.ts。大概在L11680, L11750:

    /**
    !#en Adds this vector. If you want to save result to another vector, use add() instead.
    !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
    @param vector vector

    @example 
    ```js
    var v = cc.v2(10, 10);
    v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
    ``` 
    */
    addSelf(vector: Vec2): Vec2;		
    /**
    !#en Adds two vectors, and returns the new result.
    !#zh 向量加法,并返回新结果。
    @param vector vector
    @param out optional, the receiving vector

    @example 
    ```js
    var v = cc.v2(10, 10);
    v.add(cc.v2(5, 5));      // return Vec2 {x: 15, y: 15};
    var v1;
    v.add(cc.v2(5, 5), v1);  // return Vec2 {x: 15, y: 15};
    ``` 
    */
    add(vector: Vec2, out?: Vec2): Vec2;		


    /**
    !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
    !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
    @param num num

    @example 
    ```js
    var v = cc.v2(10, 10);
    v.mulSelf(5);// return Vec2 {x: 50, y: 50};
    ``` 
    */
    mulSelf(num: number): Vec2;		
    /**
    !#en Multiplies by a number, and returns the new result.
    !#zh 缩放向量,并返回新结果。
    @param num num
    @param out optional, the receiving vector

    @example 
    ```js
    var v = cc.v2(10, 10);
    v.mul(5);      // return Vec2 {x: 50, y: 50};
    var v1;
    v.mul(5, v1);  // return Vec2 {x: 50, y: 50};
    ``` 
    */
    mul(num: number, out?: Vec2): Vec2;		

谢谢…

怎么解决的,,我用add函数还是不是。还是不识别函数。。文档里面有那个add函数

1.10 以后,cc调用的方法,大部分不再单独实现,需要使用对应的类的实例来实现,或者自己来实现。
可以看一下这个文件:https://github.com/cocos-creator/engine/blob/2.0.0/cocos2d/deprecated.js

1赞