@Override
    public void update() {
        // Check user input and create more balls or turn on/off collision detection
        // as requested
        if( this.gameEngine.inputEvent.keyTyped( KeyEvent.VK_1 ) )
            this.createBalls( 1 );
        else if( this.gameEngine.inputEvent.keyTyped( KeyEvent.VK_2 ) )
            this.createBalls( 10 );
        else if( this.gameEngine.inputEvent.keyTyped( KeyEvent.VK_3 ) )
            this.createBalls( 100 );
        else if( this.gameEngine.inputEvent.keyTyped( KeyEvent.VK_4 ) ) {
            enableCollisionChecking = !enableCollisionChecking;

            // Update each ball so that it cannot intersect other objects, 
            // i.e. it cannot be involved in collisions. It is also necessary
            // to ask the CollisionLayer to remove any arbiters (current points
            // of contact) for the body.
            GameObjectCollection balls = getGameObjectCollection( "Balls" );
            for( int idx = 0; idx < balls.size; idx++ ) {
                balls.gameObjects[idx].canIntersectOtherGraphicalObjects = enableCollisionChecking;
                removeArbitersForBody((Body)balls.gameObjects[idx]);
            }
        }
        
        // Rebound the ball if it leaves the game layer
        GameObjectCollection balls = getGameObjectCollection( "Balls" );
        for( int idx = 0; idx < balls.size; idx++ )
            GameObjectUtilities.reboundIfGameLayerExited( balls.gameObjects[idx] );
        
        // Call the update method of the CollisionLayer which will update bodies
        // based upon their velocities, etc. and interaction with other bodies.
        super.update();
    }