Welcome to Phrogram Sign in | Join | Help


UnloadSprite() and Arrays

  •  11-18-2006, 9:09 AM

    UnloadSprite() and Arrays

    I see in one of the space ship shooter example programs that a sprite can be unloaded and then loaded again to reuse it. I understand how this works and can make it happen with a single sprite. I am working on a program and wanted to use this concept in an array so I can reuse the array to load similar enemy sprites at different points in the program. My UnloadSprite() line looks like -- UnloadSprite(Enemy[i].ShipSprite.Name) --

     

    I think the idea is sound, but when I run through the For loop to unload the sprites in the array - it does not seem to really unload them. When I run the program again and try to populate the array for a second time, it errors out and says the first array items (i.e. Enemy1 sprite name) are still loaded. I found that if I clear the sprite name in my For loop (that unloads the array sprite) with a -- Enemy[i].ShipSprite.Name = ""  -- then the sprites are unloaded how I want.

     

    Just for my own curiousity, am I not understanding the funciton of the UnloadSprite() correctly or was this not meant to be used in an array the way I am trying?

     

    Thanks for the help. 

View Complete Thread