We're starting with the Explosion
classes because they don't create instances of any other classes. A depth-up kind of strategy is as good as any for this kind of testing.
Open the
ExplosionClasses_00.py
file from theChapter12
folder.Add the following method to the bottom of the
Pop
class:def __del__(self): print("Pop Removed")
Add this method to the bottom of the
Boom
class:def __del__(self): print("Boom Removed")
Resave the file with the same name and run the game. Watch the command prompt for our prints when
Pops
andBooms
vanish.We don't see the prints! That's because we have two errors in our classes that need to be fixed. Firstly, we're using a
Sequence
to call ourdestroy
method after a set amount of time, but we aren't starting thatSequence
so ourdestroy
method is never called! Add this line of code to the bottom of the__init__
method for both classes:self.seq.start()
The second error is a little more...