A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Simple Hittest problem

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    9

    Cow Icon Simple Hittest problem

    I've been trying to write a hittest that will work for rounded walls on my RPG D: But i've been epic phailing. Heres my code:

    onClipEvent(load){speed=10;}onClipEvent(enterFrame ){if(Key.isDown(Key.UP)){this._y-=speed;this.gotoAndStop(5);}if(Key.isDown(Key.DOWN )){this._y+=speed;this.gotoAndStop(6);}if(Key.isDo wn(Key.RIGHT)){this._x+=speed;this.gotoAndStop(7); }if(Key.isDown(Key.LEFT)){this._x-=speed;this.gotoAndStop(8);}

    If someone could help me out I would love them forever <3

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Location
    CleVegas (aka Cleveland), TN
    Posts
    11
    okay... i've dealt with rounded hit test stuff like this before. What you want to do is check the distance between you and the center of the rounded wall.

    Essentially you check for the hypotenuse.

    Code:
    !!!not actual coding!!!
    
    if (( (y*y) + (x*x) ) < radius_of_wall*radius_of_wall)
    {
    hittest = true;
    }
    42 is not the answer to life, the universe, and everything... Dr Pepper is.

  3. #3
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    I don't see any hit test code in what you have above so I am not too sure what is going on there. you can use this for a hit test

    use:

    mc.hitTest(x, y, shapeFlag) shapeFlag set to true, will fire if you hit actual "pixels" not the bounding box.

    or use:

    mc.hitTest(target) target is the movieclip you want to check against, it will check actual pixels not bounding box.

    not sure that is what you are looking for though

    IMS

Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center