PDA

View Full Version : Detect object stop with x & y



onemhunki
August 12th, 2005, 10:33 AM
Folks,

I'm trying to detect when an object (a golf ball) in my game stops bouncing. I need to track it's x and y position and tell when they both equal a set figure (the hole) a hitTest wasn't working as it was detecting each ball bounce not when it stopped rolling. So when the x and y both equal a figure. I'm not sure of the two operators needed to get this figure, can anyone help.

if ((this._x = -106.5) && (this 47.55)){
_root.cheer.play();
}

This doesn't seem to work.

Cheers all

Munki

stringy
August 12th, 2005, 10:41 AM
Not sure how you are moving your golfball but you are better detecting if it is close to the hole rather than detecting if its coordinates are the same as the hole
eg/
if(Math.abs(hole._x -this._x <5) && Math.abs(hole._y-this._y)<5){
dostuff
};

onemhunki
August 12th, 2005, 10:56 AM
Cheers mate,

Sounds logical, I'll give it a try.

Munki

onemhunki
August 12th, 2005, 11:28 AM
I keep getting a type mismatch error with that code.

stringy
August 12th, 2005, 12:54 PM
I keep getting a type mismatch error with that code.
heres a quick example

onemhunki
August 15th, 2005, 05:26 AM
Cheers Stringy,

There's definatley something I can use there. I'll let you know how I get on.

Cheers

Munki