Be a Supporter!

Problem with HitTest

  • 385 Views
  • 3 Replies
New Topic Respond to this Topic
Floirt
Floirt
  • Member since: Nov. 3, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Problem with HitTest 2007-05-23 15:48:47 Reply

Hello,
I need some help.
I want to draw a maze, and a character would move in, without touching the walls or he "dies" (well, he just go to the "play level" frame)
But when i draw my maze, convert it to movieclip and stuff,
when I test, it goes back directly to the "play level" screen.
So, is there a way to draw the maze directly, or i have to use symbols and rotate/skew/etc. my walls?

Thanks,

Floirt

FatalFuryX
FatalFuryX
  • Member since: Jun. 29, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Problem with HitTest 2007-05-23 16:45:44 Reply

if (Objects.hitTest(getBounds(_root).xMax, _y, true)) {
//game over
}else if (Objects.hitTest(getBounds(_root).xMin, _y, true)) {
//game over
}else if (Objects.hitTest(_x, getBounds(_root).yMax, true)) {
//game over
} else if (Objects.hitTest(_x, getBounds(_root).yMin, true)) {
//game over
}

Try that out

-Fatal

Floirt
Floirt
  • Member since: Nov. 3, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Problem with HitTest 2007-05-24 12:00:38 Reply

Ummmm, i think i'm doing something wrong...

onClipEvent (enterFrame) {
if (this.hitTest (_root.level)(getBounds(_root).xMax, _y, true)) {
}else if (this.hitTest(getBounds(_root).xMin, _y, true)) {
}else if (this.hitTest(_x, getBounds(_root).yMax, true)) {
} else if (this.hitTest(_x, getBounds(_root).yMin, true)) {
}
}

Have i done something false here?

Thanks fatal through :)

noob-toast
noob-toast
  • Member since: May. 18, 2004
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Problem with HitTest 2007-05-24 12:03:00 Reply

You could also use shapeFlag hitTesting, which isn't what the Flash MX example of the maze does, but it still gets the job done at times.

if(maze.hitTest(_x,_y,true)){
die
}

That's a shapeflag hitTest on the Registration Point of a movieclip.


These new signatures can suck on mah balls. My lolis don't fit in. Lol wut what are you guys still doing on NG, move on.

BBS Signature