A. Study this example situation:
Yesterday morning I got up and looked out of the window. The sun was shining but the ground was very wet.
It had been raining.
It was not raining when I looked out of the window; the sun was shining. But it had been raining before. That’s why the ground was wet.
Had been ~ing is the past perfect continuous:
I/we/you/they had(= I’d etc.) been doing/working/playing etc.
he/she/it had (= he’d etc.) been doing/working/playing etc.
Some more examples:
* When the boys came into the house, their clothes were dirty, their hair was untidy and one of them had a black eye. They’d been fighting.
* I was very tired when I arrived home. I’d been working hard all day.
B. You can say that something had been happening for a period of time before something else happened:
* Our game of tennis was interrupted. We’d been playing for about half an hour when it started to rain
* Ken gave up smoking two years ago. He’d been smoking for 30 years.
C. Had been ~ing (past Perfect continuous) is the past of have been ~ing (present perfect continuous). Compare:
present perfect continuous
* I hope the bus comes soon. I’ve been waiting for 20 minutes. (before now)
* He’s out of breath. He has been running.
past perfect continuous
* At last the bus came. I’d been waiting for 20 minutes. (before the bus came)
* He was out of breath. He had been running.
D. Compare had been doing and was doing (past continuous):
* It wasn’t raining when we went out. The sun was shining. But it had been raining, so the ground was wet.
* Ann was sitting in an armchair watching television. She was tired because she’d been working very hard.
E. Some verbs (for example, know and want) are not normally used in the continuous:
* We were good friends. We had known each other for years. (not ‘had been knowing’)