Skip navigation
matt0400@aol.com
Currently Being Moderated

hitTestPoint not recognizing full shape

Nov 20, 2011 7:25 AM

Hey guys, thanks in advance for help.  Anyone know why "hitTestPoint(character.x, character,y, true)" would be hit testing off the origin point in the center of the character, and not the whole shape??

 

 

This is my code from my document class.  There's a custom splat class in there, but don't worry about that.  This code is inside 2(1 nested) for loops.

 

 

function hitTestBalls(e:Event) {

                       

                              for (var i = ballArray.length - 1; i >= 0; i--) {

                                        for (var m = MonsterArray.length - 1; m >= 0; m--) {

 

 

if ((ballArray[i].hitTestPoint(MonsterArray[m].x,MonsterArray[m].y, true)) && (MonsterArray[m].MouthClosed == true)) {

                                                            trace("219");

                                                            var splat:Splat=new Splat(ballArray[i].currentFrame*10,ballArray[i].x,ballArray[i].y);

                                                            addChild(splat);

 

 

                                                  }

 

 

                                                  if (ballArray[i].hitTestObject(MonsterArray[m].HitTester)||ballArray[i]. x>stage.stageWidth||ballArray[i].y>420) {

                                                            trace("217");

 

 

                                                            if (ballArray[i].y>420) {

 

 

                                                                      var splat2:Splat=new Splat(ballArray[i].currentFrame*10,ballArray[i].x,ballArray[i].y);

                                                                      addChild(splat2);

                                                            }

 

 

                                                            ballArray[i].updateTimer.stop();

                                                            ballArray[i].updateTimer=null;

                                                            ballArray[i].parent.removeChild(ballArray[i]);

                                                            ballArray.splice(i,1);

                                                  }

 

 

                                        }

                              }

 

                              updateScore();

                    }

 
Replies
  • kglad
    62,058 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 22, 2011 7:21 AM   in reply to matt0400@aol.com

    "hitTestPoint(character.x, character,y, true)" tests against character's registration point which can be located anywhere depending on your setup.  that reg point could be nowhere close to any pixels that you see that comprise character's shape.

     
    |
    Mark as:
  • kglad
    62,058 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 22, 2011 7:43 AM   in reply to matt0400@aol.com

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points