7 Replies Latest reply on Apr 7, 2008 4:51 PM by kglad

    Using attachMovie and hitTest.

    wesm9787
      What I'm trying to do is make a fairly basic game. As of now it's just one character controlled by the player being attacked by 3 enemies. It's basically done except for a few minor tweaks, but there's one major snag I ran across that I can't figure out. Basically I have a blank movie clip, called blank_mc, on the stage, as well as the 3 enemies. I'm using attachMovie to attach different movie clips for moving, attacking, blocking, etc. So when you attack, it attaches the attack_mc movie clip to blank_mc. I have it so all depths are the same so every time a new movie clip gets attached to blank_mc it replaces the old one. I attached the code I'm using at the bottom so you can see how I did it.

      The problem is that I can't figure out how to detect a collision between the player and an enemy while attacking without just doing "if (blank_mc.hitTest(enemy_mc))..." If I do it that way, then when there's a situation where, say, the player is facing left and attacking enemy 1 and at the same time an enemy 2 attacks from behind on the right, the enemy on the right will take damage.

      So here's what I can't figure out. I have a movie clip called sword_mc inside of attack_mc, and I want to know if there's a way to reference sword_mc and detect a hitTest between it and enemy_mc. That way an enemy will only be damaged if they're actually hit, instead of just taking damage every time they touch you while you're attacking.