Quote:
Originally Posted by xAndrewx
Is there any way to prune the unused sprites?
|
No but it wouldn't be that difficult to write a function to do so using the class.
Edit: Wrote some functions to do so.
PHP Code:
public function deleteSprite(sprite_id) {
if (sprite_id in this.sprites) {
this.sprites.remove(sprite_id);
this.sprite.(@sprite_id) = "";
return true; // Deleted Successfully
} else {
// Doesn't exist.
return false;
}
}
// HAVEN'T TESTED BUT THIS SHOULD WORK
public function removeUnusedSprites() {
temp.inuse = {};
// Determine Sprites Inuse
for (temp.f: this.frames) {
for (temp.s: temp.f) {
if (!(temp.s[0] in temp.inuse)) {
temp.inuse.add(temp.s[0]);
}
}
}
// Delete Unused Sprite Data
for (temp.s: this.sprites) {
if (!(temp.s in temp.inuse)) {
this.sprite.(@temp.s) = "";
}
}
// Update Sprite ID List
this.sprites = temp.inuse;
}