Sunday 15 January 2012

javascript - Deleting object that could have multiple pointers to it -



javascript - Deleting object that could have multiple pointers to it -

i making game lot of characters objects. when character die, want delete pointers it, problem don't know how many or these pointers are. i.e character "a", might have character "b" stored in "field of view" array, or character might saved in physics engine's "objects lying on ground" array. there way forcefulness object deleted arrays exists in?

character.prototype._delete_self () { this.delete_everywhere(); }

i have tried run trough arrays character might in, took whole lot of performance. bumped problem if ran trough array using value i, "for loop" got out of sync since got shorter. possible first delete position in array, , later compress array later on?

var arr = new array(1,2,3,4,5); arr[3]=null; document.write("1: "+arr); arr.compress(); document.write("2: "+arr);

the document:

1: 1,2,,4,5 2: 1,2,4,5

javascript arrays pointers

No comments:

Post a Comment