Destroying a Sprite or Image

Error message

Deprecated function: Function create_function() is deprecated in GeSHi->_optimize_regexp_list_tokens_to_string() (line 4698 of /home/digipiph/public_html/sites/all/libraries/geshi/geshi.php).

To destroy a sprite or image that has been added to the DGM, simply call the destroy function and pass it the sprite/image variable.

//define the gameCanvas using the HTML canvas element
var gameCanvas = dgm.setupCanvas(document.getElementById("gameCanvas"));
 
//setup a wooden block object to be destroyed
var woodenBlock_data = {
  "id": "wooden_block",
  "x": 0,
  "y": 0,
  "src": 'images/wooden-block.png'
};
 
//add the wooden block object to the canvas
var woodenBlock = dgm.configImg(woodenBlock_data, gameCanvas);
 
//after 5 seconds, destroy the block
setTimeout(function() {
  dgm.destroy(woodenBlock);
}, 5000);