0 Replies Latest reply on Nov 24, 2010 5:15 PM by Algar32

    Help coding falling blocks left and right wall in as2

    Algar32

      I have a block. It falls from the sky. My character jumps on top of it. I want the character to not be able to pass through the left and right side of the block. Can you show me how to do this? (as of right now I dont have the falling script on the block, but i will)
      Code ON BLOCK:

       

      onClipEvent (enterFrame) {
      if ((this.hitTest(this._parent.Char) && (this._parent.Char._y<258+this._height/2))) {
      this._parent.Char._y=(_y-_height/2)-this._parent.Char._height/2
      this._parent.Char.gravity = 0;
      this._parent.Char.jump= 0;
      }
      //if (this.hitTest(this._parent.Char)){
      //      if(this._parent.Char._x>_x){
      //      this._parent.Char._x=_x+(_height/2)
      //      }
      //      if(this._parent.Char._x>_x){
      //      this._parent.Char._x=_x+(_height/2)
      //      }
      //     }
      }
      onClipEvent (load) {
      var xspeed:Number = 0

       

      }

       

      Char stand for character...

       

      As of right now only the top of the block works. You can walk and jump. I just want the left and right sides to be a barrier. Please help. Thanks.