To build the complete list of tiles to be removed in the 'moveSelected' method, we can now use this:
and then later we can just use the following to remove the matching tiles:
(possibly) we may want to remove them as we replace them.
1 2 3 4 5 | List<Tile> tiles = new ArrayList(); tiles.addAll(getHorizontalMatchingTiles(tile.getX(), tile.getY())); tiles.addAll(getVerticalMatchingTiles(tile.getX(), tile.getY())); tiles.addAll(getHorizontalMatchingTiles(tile2.getX(), tile2.getY())); tiles.addAll(getVerticalMatchingTiles(tile2.getX(), tile2.getY())); |
1 | removeObjects(tiles); |