View Single Post
  #21  
Old 08-18-2013, 01:37 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by xAndrewx View Post
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.fthis.frames) {
    for (
temp.stemp.f) {
      if (!(
temp.s[0in temp.inuse)) {
        
temp.inuse.add(temp.s[0]);
      }
    }
  }
  
// Delete Unused Sprite Data 
  
for (temp.sthis.sprites) {
    if (!(
temp.s in temp.inuse)) {
      
this.sprite.(@temp.s) = "";
    }
  }
  
// Update Sprite ID List
  
this.sprites temp.inuse;

__________________
Quote:

Last edited by fowlplay4; 08-18-2013 at 01:54 PM..
Reply With Quote