Skip to main content
2 of 2
added 299 characters in body
Elva
  • 3.2k
  • 1
  • 21
  • 31

Javascript does not support operator overloading (i.e. specifying how "-" on something that isn't a number should work), you should call whatever functions your vectors provide for that (I can't find any documentation that cocos2d-js provides that API).

The NaN is because javascript is going "I don't know how to multiply these 2 things that aren't numbers, so that's Not A Number (NaN)"

velocityComputer: function(inVector, thisNVector) {
    var prodVec = cc.pDot(inVector, thisNVector);
    var retVec = cc.pSub( inVector, cc.pMult( cc.pCompMult( prodVec, inVector ), 2 ) );
    cc.log(retVec);
    // cc.log(blockNVec);
    return retVec;
},
Elva
  • 3.2k
  • 1
  • 21
  • 31