Referencing our boundaries

Just as we assigned a value to our reference in our rocks, we will do the same for both our boundaries. We will do so in our surfaceCreated() method by adding the variables marked in bold: 

    @Override    public void surfaceCreated(SurfaceHolder holder){upperBoundary = new ArrayList<UpperBoundary>();    lowerBoundary = new ArrayList<LowerBoundary>();    }

Looks neat! Now comes the tricky part. We will have to write the update logic for both our boundaries. Don't confuse this with the update() method in our individual boundaries. That update method will simply make our ground move backward. We will also need to actually write the logic to spawn them on screen. Let's see how to do that.

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.