I am trying to create a canvas game using the proccessing.js library.
I use an array to hold all my objects.
class blah{
...
void delete(){
// this.remove ???
}
}
blah myArray = [];
myArray.push(new blah());
Is there a way I can create a delete function inside that class so that when the element is deleted it is removed from the array? I have thought of a workaround like passing as an argument the element's position in the array. Isn't there a direct way to delete it without passing any argument?
The workaround I told above:
void delete(int i){
myArray.splice(i,1);
}