2017-06-17 33 views
0

こんにちは私はプログラミングには新しく、運動をしようとしている間にこのエラーがポップアップしていましたが、どういう意味でどのように修正するのか分かりません。 これは、コピーしようとしたあとでうまく行かなかったというprocessing.jsライブラリの例です。メソッドの戻り値の型がprocessing.jsにありません

Mover mover; 

    void setup(){ 
     size (600,600); 
     mover = new Mover(); 
    } 

    void draw(){ 
     mover.update(); 
     mover.display(); 
     mover.checkEdges(); 

    } 
    class Mover { 

    // position, velocity, and acceleration 
    PVector position; 
    PVector velocity; 
    PVector acceleration; 

    // Mass is tied to size 
    float mass; 

    Mover(float m, float x, float y) { //<<<the error occurs here 
    mass = m; 
    position = new PVector(x, y); 
    velocity = new PVector(0, 0); 
    acceleration = new PVector(0, 0); 
    } 

    // Newton's 2nd law: F = M * A 
    // or A = F/M 
    void applyForce(PVector force) { 
    // Divide by mass 
    PVector f = PVector.div(force, mass); 
    // Accumulate all forces in acceleration 
    acceleration.add(f); 
    } 

    void update() { 

    // Velocity changes according to acceleration 
    velocity.add(acceleration); 
    // position changes by velocity 
    position.add(velocity); 
    // We must clear acceleration each frame 
    acceleration.mult(0); 
    } 

    // Draw Mover 
    void display() { 
    stroke(255); 
    strokeWeight(2); 
    fill(255, 200); 
    ellipse(position.x, position.y, mass*16, mass*16); 
    } 

    // Bounce off bottom of window 
    void checkEdges() { 
    if (position.y > height) { 
     velocity.y *= -0.9; // A little dampening when hitting the bottom 
     position.y = height; 
    } 
    } 
} 

答えて

0

私はあなたのコード内で参照唯一の問題は、あなたのMoverコンストラクタは3つの引数を取りますが、あなたは、この行でいずれかを与えていないということです。

mover = new Mover(); 

だから私は修正したいですその前にそのエラー。それでも問題が解決しない場合は、このコードをどのようにコンパイルして実行しているかを具体的に記述してください。処理エディタを使用していますか?どのバージョン?正確にどのステップでエラーが発生しますか?

関連する問題