# Hit detection for gaming

**URL:** <https://forum.kirupa.com/t/hit-detection-for-gaming/96407>\
**Category:** Uncategorized\
**Created:** [December 9, 2003, 3:02am UTC](https://forum.kirupa.com/t/hit-detection-for-gaming/96407 "2003-12-09T03:02:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelloKittyGurl](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@HelloKittyGurl](https://forum.kirupa.com/u/HelloKittyGurl)\
**Post date:** [December 9, 2003, 3:02am UTC](https://forum.kirupa.com/t/hit-detection-for-gaming/96407/1 "2003-12-09T03:02:46Z")

</div>

I am making a game and I want to make it so that if something get’s hit 3 times than it jumps to a new frame. This is a pong type game and so I want it so that there is a boss who gets hit three times then a movie clip with flowers comes out. If anyone has scripting that can help I will be really, really happy.  
Roxy Gurl:)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 13, 2003, 6:47pm UTC](https://forum.kirupa.com/t/hit-detection-for-gaming/96407/2 "2003-12-13T18:47:14Z")

</div>

Well… If this is a pong type game then my guess is you have a series of boxes and a ball… 2 paddles or one… if it’s a block hitting style…

So… You will hopefully find this piece of code to be very useful… 😃

[AS]

// Found in the block’s movieclip. the one you are copying

onClipEvent(load)  
{  
this.strength = 3; // How many times you hit it for it to progress  
this.hitLevels = 2; // How many times you can knock it before deleting  
this.holder = this.strength;  
}

onClipEvent(enterFrame)  
{  
if(this.hitTest(\_root.ball.\_x, \_root.ball.\_y, TRUE))  
{  
this.holder–;  
if(this.holder == 0)  
{  
this.holder = this.strength;  
this.hitLevels–;  
if(this.hitLevels == 0)  
{  
this.removeMovieClip();  
}  
else  
{  
this.gotoAndPlay(2);  
}  
}  
}  
}

[/AS]

Hopefully this works out for you… 😃
