Say I have a cupboard door in a room, when the player interacts with it it is opened and there is are several objects behind it. The only way I would know how to have an open-able cupboard door would be to make the door itself be an object, so then how do I have other objects behind it hidden until it's opened?
So, what's the problem? If object is hidden it doesn't matter if it is in front or behind the door. And when door is open the door object itself is moved, so it doesn't matter again if it is back or in front. Or am I missing something?
I'm presuming you mean that with the cupboard's contents you only want one object to be visible at a time. If that's the case, it's fairly easy - there are two approaches:
1) have a single object that's going to represent all the objects you can take from the cupboard which is behind the cupboard object in z-order, so it immediately appears as you cycle the cupboard object through an opening animation. As the user clicks on the object to take it, if there are still more objects remaining to be seen, you simply change the object graphic each time, and have your look/interact event handlers check the current graphic (or use a flag) to display messages appropriate to looking at or taking what the object is now.
2) The other way is to have separate objects for each object in the cupboard, with all the objects but the first visible one turned off by default. Then as you click interact on each object to pick it up, at the same time you turn the current object off, you turn on the next one in the sequence.
DreamMaster.
There are two basic ways I can see, if I understand the problem:
1) Baselines
Set the objects-in-the-cupboard baselines higher than the door object baseline. The objects in the cupboard should be hidden behind the closed door, but not the open door. You could then play about with the object baselines to set which are further forward on the shelves. (I think this is what BorisZ was assuming.)
2) Object On/Off
Kind of like dreammaster said. Turn the objects in the cupboard on when you open the door, and off again when you close it, except with multiple objects, not just one at a time.