我正在尝试使用 box2dweb console.log 对象的速度应该可以使用以下方法 GetLinearVelocity() 获得速度,但我不知道该怎么做? 我尝试过以下方法:
var heroMove = GetLinearVelocity().hero;
console.log('heroMove');
和
var heroMove = GetLinearVelocity('hero');
console.log('heroMove');
在控制台中我收到消息:
ReferenceError: GetLinearVelocity is not defined
这可能是一个简单的答案,但似乎没有 jquery.box2d 的文档,我看不出有什么问题?
最佳答案
我自己找到了解决方案。它看起来像这样:
var heroVelX = game.currentHero.GetLinearVelocity().x;
var heroVelY = game.currentHero.GetLinearVelocity().y;
console.log("X =", heroVelX + "Y =", heroVelY);
GeltLinearVelocity() 的值是一个向量而不是数字,因此必须指定为 x 和 y。希望其他人可以使用它。
关于javascript - Console.log 使用 box2d 记录对象速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26347638/