Good question!
It's my oversight that there isn't a delete method for Gobs. I'll make
sure to add the method to the engine code.
In the interim, you can delete Gobs using these three steps:
1) First, if you explicitly added events to your Gob's tag, then
remove them. (You probably didn't, but just in case, here's the
instructions:)
// this example uses 'onclick'
// skip this step if you didn't add an 'onclick','onmousemove',
etc.
G.O['gobID'].tag.onclick = null;
1) Second, delete the Gob's HTML tag from the DOM.
// 'parentNode' is a built-in DOM attribute of every HTML tag
// and 'removeChild(node)' is a built-in DOM method
// lets put them together to remove the tag from its parent:
var gob = G.O['gobID'];
gob.tag.parentNode.removeChild(gob.tag);
2) Third, delete the Gob's javascript object from any sets of Gobs
that reference it. Once all references are deleted, the browser's
javascript engine will do garbage collection and recover the memory
used by the Gob.
// G.O is the global Gob set, and this reference
// definitely needs to be deleted. To delete the reference,
// we use the delete keyword.
delete G.O['gobID'];
// did you manually make a reference in a Block's Gob set?
// If so, then delete that/those references too.
delete G.B['someBlock'].O['gobID'];
That's it! You probably only need to do the second step in most cases,
but the other steps may crop up.
In the next few days, I'll be adding code to the engine that does this
same work, and then testing it and releasing it. I'll post something
here as well!
As an aside, I think overlooked the delete method because of the way I
code my games. I tend to create one big master set of Gobs, and just
turn them off and on as I need them. But it's definitely an oversight
not to have a good delete method, so I'll be adding it asap!
Cheers,
Trev