0

これが非常に単純な問題である場合は申し訳ありません。rectを処理ウィンドウの側面からバウンスさせるにはどうすればよいですか。エラーメッセージの意味もわかりません。「演算子*=は引数の型PVectorintに対して未定義です」。

PVector position, velocity, scaler, scaleSpeed, blurValue, blurSpeed;
PImage avatar;

void setup()
{
  size(600,600);
  avatar = loadImage("BlackPower.png");
  position = new PVector(0, 0);
  velocity = new PVector(2,0);
}

void draw()
{
  background(255);
  translate(position.x, position.y);
  position.add(velocity);

  fill(0);
  rect(50,50, 200,50);

  if(position.x>width || position.x<0 || 
     position.y>height  || position.y<0)
   {
     velocity*=-1;
   }
}
4

2 に答える 2

2

PVectorは数値ではありません。何かを掛けたい場合は、mult()を使用してください-http: //processing.org/reference/PVector.html

于 2013-03-18T23:40:23.373 に答える
0

速度.mult(-1)を使用してベクトルに-1を掛けるか、velocity.rotate(180)を使用してベクトルを180度回転させることができます。

于 2021-11-06T11:56:27.330 に答える