The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 4 of 4

Thread: Collision Tests with Walls, Obstacles, etc.

  1. #1
    Game-Designer in Training

    Fla Script Collision Tests with Walls, Obstacles, etc.

    Very simple question (I'm an AS n00b, I know...):

    What's the best way to stop a Movie Clip's movement in a specific direction (ie. when you move into a wall or the side of the stage)?


    EDIT: this is Flash MX I'm using.
    Last edited by JapanMan; June 21st, 2008 at 07:13 PM.

  2. #2
    i usually test a point in the direction they are trying to move with hitTest(x + x_speed, y + y_speed) first, and then only move if it's clear. some people i think move, then test, then move back if something is hit.

    something like this:

    if (Key.isDown(Key.RIGHT)) {
      x_speed = 5;
      y_speed =0;
    // more of these for directions
    if (_root.clipping_map.hitTest(_x + x_speed, _y + y_speed) == false) {
      _x += x_speed;
      _y += y_speed;

  3. #3
    Game-Designer in Training
    so, in the instance of your code, "map" would be the wall or obstacle, and the code would be in the moving Movie Clip's actions, correct?

  4. #4
    yeah, clipping_map is just a vector drawing with solid where they can't walk, and you can do onClipEvent(load) { _visible = false; } in it to make it invisible. and the code in the example is attached to the moving movie clip.

    uh, i messed up a line tho. it should say:

    if (_root.clipping_map.hitTest(_x + x_speed, _y + y_speed, true) == false) {

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012