;

PDA

Click to See Complete Forum and Search --> : Hittest not working?


marinebro0306
08-27-2005, 05:51 PM
I've tried everything, and I can't get hitTest to work.
I am just experimenting with how to use it, and I have 3 MC's. 1 is called circle, the other star, and the last test. I have the code pasted into 'circle', and test is a little figure that should show when circle and star collide. But, the 'test' MC never shows.

My script:
onClipEvent (enterFrame) {
if (_root.circle, hitTest(_root.star)) {
setProperty ("_root.test", _visible, true);
} else {
setProperty ("_root.test", _visible, false);
}
}

I am using Koolmoves v. 5.0.2, so the previous setProperty problem was resolved. What am I doing wrong???

pherbrick
08-27-2005, 11:58 PM
You have a typo in your hitTest call.


if (_root.circle, hitTest(_root.star)) {

should be

if (_root.circle.hitTest(_root.star)) {

marinebro0306
08-28-2005, 12:13 AM
You have a typo in your hitTest call.


should be

Still doesn't work...I got the script from a tutorial.

See attached file.

blanius
08-28-2005, 09:52 AM
not to add to your confusion but if you want to hittest circles it's better to use a distance test rather than hittest as hittest will trigger if the bounding rectangle hits.

function distance(element1,element2)
{
a=element1.x - element2.x;
b=element1.y - element2.y;
return sqrt (a*a+b*b);
}

marinebro0306
08-28-2005, 10:54 AM
not to add to your confusion but if you want to hittest circles it's better to use a distance test rather than hittest as hittest will trigger if the bounding rectangle hits.

function distance(element1,element2)
{
a=element1.x - element2.x;
b=element1.y - element2.y;
return sqrt (a*a+b*b);
}

Thanks for the lesson, but I'm still stuck on the hitTest action. When (and if) wo opened the file, could you get it to work? Even with circle shapes clearly intersecting, it would not work.

pherbrick
08-28-2005, 02:45 PM
To fix:
1) Remove the second frames from movieclips circle and star,
2) On the main timeline, use Add Copy of Frame to End,
3) On Frame 2 of the main timeline, position movieclips circle and star at their farthest point.