From the course: Building Flash Games with Starling
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Implementing the destroy method
From the course: Building Flash Games with Starling
Implementing the destroy method
So now we have our basic game play completed. So we have our collisions happening and we determined when we're going to go to the GameOver state. But now we need to clean up after ourselves in the play state. So we need to implement the destroy methods. So first, let's go to our BulletManager. So in our Manager classes, we need to do a couple of things in the destroy method. First, we're going to destroy the pool. So to do that, we're going to call the destroy method of the pool. Then we're going to set pool = null and we're also going to set our array to null. So our array here is called bullets, and we'll set it equal to null. When it comes to cleaning up after yourself and garbage collection in Flash, it's better to do too much than not enough. So it's somewhat of a mystery sometimes about how to force things to be reclaimed in memory, so it's better just to go overboard and just be sure that you're cleaning up after yourself. So we're going to copy this because we're going to do a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
Adding the background1m 3s
-
Creating the Hero class6m 14s
-
Creating the Bullet class1m 44s
-
Creating the BulletManager class4m 23s
-
Using the StarlingPool class9m 24s
-
Firing bullets with the mouse7m 24s
-
Creating the Alien movie clip1m 58s
-
Creating the AlienManager class8m 12s
-
Overview of collision-detection options3m 10s
-
Creating the CollisionManager class10m 51s
-
Implementing the destroy method2m 24s
-
-
-
-
-