【发布时间】:2016-09-08 01:31:50
【问题描述】:
我正在尝试编写一个简单的“跟随鼠标”程序,但是下面的代码会抛出一个错误,指出静态 .sub() 方法不存在:
void update()
{
PVector mouse = new PVector(mouseX, mouseY);
PVector direction = PVector.sub(mouse, location); // dir = mouse - location
direction.normalise();
direction.multiply(0.4);
acceleration = direction;
velocity.add(acceleration);
velocity.limit(maxVelocity);
location.add(velocity);
}
我自己定义了一些方法(方法重载?),因此为什么我们有 'multiply' 而不是 'mult' 等等,但我不明白为什么它告诉我 .sub() 没有'不存在,当它是clearly there in the documentation。我也有其他一些方法。
我需要定义自己的静态 .sub() 吗?你甚至可以在处理中做到这一点吗?
提前致谢。
【问题讨论】:
-
你能发布你的自定义鼠标追逐类吗? (不清楚你如何使用
PVector:party 看起来像使用组合,但部分扩展了类,但使用与超类相同的名称,这可能与它有关)
标签: processing