We now have a list of gems to be removed, so it's time to remove them from the game.
The idea: Scan through the
gemsToRemove array and remove all the gems.
The development: Removing a gem takes two steps: removing the gem DisplayObject from Display List, and update
jewels array. This leads to a question: if
jewels array contains element from
6 to represent different gem types, how can we code the "empty" status? We'll use
-1 to say there isn't any gem in the
The first thing to do is looping through the
gemsToRemove array, and we'll do it using the
forEach method as we did during the making of Astro-Panic! although we used it on a Vector.
forEach method works in the same way with arrays too. Add this line ...