1 Reply Latest reply on Sep 13, 2006 7:56 AM by kglad

    Problems with flash game, hitTest

    Lim€
      Hi!

      I have tried to create a simple arcade game in Flash 8. I saw a tutorial at ( Flashkit.com, i followed it but when I came to the part with walls, page 10, it didn´t work. Here is the code I used, from the tutorial:

      quote:



      onClipEvent (load) {

      moveSpeed = 7;

      }

      onClipEvent (enterFrame) {

      if (Key.isDown(Key.RIGHT)) {

      this._x += moveSpeed;

      } else if (Key.isDown(Key.UP)) {

      this._y -= moveSpeed;

      } else if (Key.isDown(Key.DOWN)) {

      this._y += moveSpeed;

      } else if (Key.isDown(Key.LEFT)) {

      this._x -= moveSpeed;

      }

      }

      onClipEvent (enterFrame) {

      if (this.hitTest(_this.wallleft)) {

      _x = _x+10;

      }

      }

      onClipEvent (enterFrame) {

      if (this.hitTest(this.wallup)) {

      _y = _y+10;

      }

      }

      onClipEvent (enterFrame) {

      if (this.hitTest(this.walldown)) {

      _y = _y-10;

      }

      }

      onClipEvent (enterFrame) {

      if (this.hitTest(this.wallright)) {

      _x = _x-10;

      }

      }

      code


      Please help me.
        • 1. Re: Problems with flash game, hitTest
          kglad Adobe Community Professional & MVP
          unless your walls are child movieclips of the movieclip to which that code is attached you have an incorrect path to the walls.

          instead of using this.wallleft etc, try this._parent.wallleft.

          p.s. don't use duplicate onEnterFrame handlers: all the code should be in one onEnterFrame handler.