BEHIND THE OBJECTS

Look to our sample. Click in the figure to activate.Use the arrow keys to walk. Try to go in front and behind the box.

The trick is: we have 2 boxes: one is part of the scenery in a layer behind the "flashy man" and another is a movie-clip and it is in a layer in front of the character.

Under the box we have:

The new movie-clip (its name is: smb) has a program:

onClipEvent(load){
 this._visible=false;
}

onClipEvent (enterFrame) {
 behind=0; 
 if (hitTest(_root.base._x, _root.base._y, true)){
  behind=1;
 }
 else{
  behind=0;
 }
}

And the box of the layer in front of the character has another program:

onClipEvent(load){
 this._visible=false;
}
onClipEvent(enterFrame){
 if(_root.smb.behind==1){
  this._visible=true;
 }
 else{
  this._visible=false;	
 }
}

This makes the box to stay in front of the character when he is over the "shadow-for-man-behind".


PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE