Be a Supporter!

hitest help

  • 230 Views
  • 5 Replies
New Topic Respond to this Topic
JCesta
JCesta
  • Member since: Jul. 8, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
hitest help 2005-10-07 19:07:36 Reply

i have an MC of a boss. the boss has different parts that damage the player if he touches them but the parts get damaged if the bullet touches them.

onClipEvent (enterFrame) {
if (this.hitTest(this._parent.player)) {
_root.health -= 10;
}
if (this.hitTest(_root.bullet)) {
play():

}
}

for some reason this doesnt work, i check all my instances. could it be because the bulet is a duplication?

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to hitest help 2005-10-07 19:10:54 Reply

What doesn't work? Does the play() command not work? If so just change it to _root.play();

JCesta
JCesta
  • Member since: Jul. 8, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to hitest help 2005-10-07 19:15:14 Reply

no, the play command is supposed to take the part of the boss and play the frame were it explodes. the part of the boss is were this code is in.

ShotInTheHead
ShotInTheHead
  • Member since: Dec. 20, 2002
  • Offline.
Forum Stats
Member
Level 31
Blank Slate
Response to hitest help 2005-10-07 19:31:10 Reply

looks like the problem is the part taht says this._parent.player

replace it with _root.player (and you never need to use "this" in nearly anything)

JCesta
JCesta
  • Member since: Jul. 8, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to hitest help 2005-10-07 19:43:24 Reply

no that just fixed the health but the bullets still dont do anything

ShotInTheHead
ShotInTheHead
  • Member since: Dec. 20, 2002
  • Offline.
Forum Stats
Member
Level 31
Blank Slate
Response to hitest help 2005-10-07 19:46:54 Reply

if youre duplicating your bullets, then chances are its instance naem problems. you cnatj ust name em all bullet. its gonna be bullet1 bullet2 bullet3 etc. then run a loop to check for each bullet##

for(i=0;i<30;i++) {
//checks for anything named bullet1 to bullet30
if (this.hitTest(_root["bullet"+i])) {
//put your scripts here
}
}