Condition still true so statement repeats itself

Hey I’m trying to debug a game I’ve been developing over the past few months.
Its about manoeuvering a bubble through the level without touching anything.
Quite similar to ‘Soap Bubble’ for those of you who have played it.

So here’s my problem, I want the bubble to play a “bursting” animation when it touches the wall using this code:

if (bubble.hitTest(wall)){
_root.bubble.gotoAndPlay(“bursting”);
}

However, as the condition is still true after one or two frames it will begin the animation again and again.

How can I fix this so that it will only play once even if it is still touching the wall?

Thanks

That depends on how you’re running that code. You’ll just need to stop running it once it hits the first time.

delete this.onEnterFrame lol :stuck_out_tongue:

I’m not exactly sure how I’m running it, (I’m not exactly a programmer)
If it’s any help it’s under this:

_root.onEnterFrame = function ()
{

And I don’t have this.onEnterFrame in the file at all.

You need to assign an additional variable against which to check your if statement, e.g.


burst = false;
if (!burst && _root.bubble.hitTest(wall)) {
	burst = true;
	_root.bubble.gotoAndPlay("bursting");
}

fan bloody tastic
your a star

Cheers dude