Let's say that we have a photograph and want to animate an object moving
and hide it self behind the building of the image.
Before begin we need to set an image as background pressing "ALT-B".
After the assignment select "Match Bitmap" from the Aspect Ration and "Lock Zoom/Pan".
In order to hide the object in this case a sphere we need to cover the building.
To do so we can create a line across the building and extrude it a little like the image below.
Then apply for material the "MATTE SHADOW" and move the sphere behind the extruded line as showing the picture.
If you render now you will get this.