Dragonfly Q&A

How to remove music in df::ResourceManager::unloadMusic

0 like 0 dislike

Unlike a df::Sound or a df::Sprite, df::Music cannot be copied, meaning that the array df::ResourceManager::music cannot be shifted over when df::ResourceManager::unloadMusic( ) is called, as the line below fails:

this->music [ y ] = this->music [ y + 1 ];

 How should we handle this?

Dragonfly version v4.0
asked Sep 24, 2015 by Andrew

1 Answer

0 like 0 dislike

Good point, and the book talks about this on page 177, right before section 4.14.3. I should add to the slides since it differs from sounds and sprites....

Since the music items in the array cannot be scooted over as you indicate, just set the label to empty ("") - that way it won't be found again.

this -> music[y].setLabel("");

And, of course, you also then don't want to decrement the music count, either.

answered Sep 25, 2015 by claypool
Ok, I added a note to the slides, too, for clarity.
More information about Dragonfly can be found on the Dragonfly Home Page.