Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hittest action performed once only? 1

Status
Not open for further replies.

janinja

Technical User
Nov 28, 2000
18
NZ
Hello,

I've made a game and set an action so that the score increments when two movie clips collide:

onClipEvent (enterFrame) {
if (this.hitTest(_root.sleigh.present)) {
var /:lost = number(/:lost)+1;
}
}

But I'm finding that instead of incrementing once only, it continues to increment all the while the clips are colliding, resulting in the score incrementing by 2 or 3.

Does anyone know a simple way around this?

thanks

ninja : )
 
Set a variable when it's hit:

Code:
onClipEvent (enterFrame) {
    if ((this.hitTest(_root.sleigh.present))&&(!sleighHit)) {
        var /:lost = number(/:lost)+1;
        sleighHit = 1;
    }
}
 
That was posted by myself, not prasadalone.

I hate that forum bug. frozenpeas
 
Thanks Frozenpeas, that worked. But I found that it only did it once, and then once the sleighit var had been defined it wouldn't work again.

In the end I worked around the problem by telling the colliding movie clip to skip the rest of the frames of the collision and carry on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top