javascript - Processing.js - Is there a destructor? -
this might naive question, there destructor in processing.js? know regular processing java-based there isn't destructor, i'm not sure if processing.js runs same way.
just it's here, here's class want build destructor for, if needed:
// 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); } }
processing.js doesn't control memory allocation or cleanup, it's left javascript engine. once remove references object, js engine queue object garbage collection, , free memory whenever needs to, afterwards.
Comments
Post a Comment