0

素朴な質問かもしれませんが、Processing.js にデストラクタはありますか? 通常の Processing は Java ベースなのでデストラクタがないことは知っていますが、Processing.js が同じように実行されるかどうかはわかりません。

ここにあるので、必要に応じてデストラクタを作成したいクラスを次に示します。

// Obstacle Class
class Obstacle {
    float r,g,b;
    float x, y, w, h;
    float speed;

    Obstacle(float x_pos, float y_pos, float width, float height, float sp) {
        // Initialize Color
        r = random(255);
        g = random(255);
        b = random(255);

        // Initial Size
        w = width;
        h = height;

        // Initial Position
        x = x_pos;
        y = y_pos;

        // Initialize Speed
        speed = sp;
    }

    void update() {
        y += speed;
    }

    void draw() {
        fill(r,g,b);
        rect(x,y,w,h);
    }
}
4

1 に答える 1

1

Processing.js はメモリの割り当てやクリーンアップを制御せず、すべて JavaScript エンジンに任せています。オブジェクトへのすべての参照を削除すると、JS エンジンはオブジェクトをガベージ コレクションのキューに入れ、後で必要なときにいつでも実際にメモリを解放します。

于 2013-05-05T02:46:10.147 に答える