Forum Topic: hitTest

(312 views • 8 replies)

This topic is 1 page long.

<< < > >>
None

ilikerps

Reply To Post Reply & Quote

Posted at: 10/26/05 07:57 PM

ilikerps NEUTRAL LEVEL 07

Sign-Up: 10/23/03

Posts: 43

I need to do a hitTest between 2 MC circles, however they act as squares. Using a shapeFlag doesn't seem to work because you need to hit the center point, which will not work in my program.
Anyone have any ideas?


None

Blaze

Reply To Post Reply & Quote

Posted at: 10/26/05 07:59 PM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,957

try changing the circles registration point to the center of it.


None

RiftMaster

Reply To Post Reply & Quote

Posted at: 10/26/05 08:02 PM

RiftMaster EVIL LEVEL 11

Sign-Up: 03/17/01

Posts: 712

Or you could go the hardcore route and use the pythagoran theorem. I bet GG could explain it to you.

I put the "funk" in function()


Questioning

ilikerps

Reply To Post Reply & Quote

Posted at: 10/27/05 07:06 AM

ilikerps NEUTRAL LEVEL 07

Sign-Up: 10/23/03

Posts: 43

I apologize, but I am not completely sure what a registration point is. I have put the circles in the middle of their MC's (like -8, -8 for a size 16, 16 MC) but I am unsure if that is what you meant.

And I cannot see how the Pythagorean Theorem would help.... Maybe if that could be expanded on?


None

DrWhat

Reply To Post Reply & Quote

Posted at: 10/27/05 07:14 AM

DrWhat EVIL LEVEL 12

Sign-Up: 09/01/05

Posts: 85

The registration point the that x thing whith a circle around it it should be the in middle by defualt

BUKKO!


None

liaaaam

Reply To Post Reply & Quote

Posted at: 10/27/05 07:31 AM

liaaaam NEUTRAL LEVEL 21

Sign-Up: 12/11/04

Posts: 12,766

The registration point is the little + thing inside the Movie Clip, you want to get that in the middle of the MC but it sounds like you've already done that. CTRL+K brings up an alignment menu which you can use to centre things accuratly anyway.

You want to do a shape flag hitTest on 360 different points to have it 100% accurate, but I'm not so good at trig so I'll leave the explanation to someone else XD


None

ilikerps

Reply To Post Reply & Quote

Posted at: 10/27/05 05:19 PM

ilikerps NEUTRAL LEVEL 07

Sign-Up: 10/23/03

Posts: 43

Okay, well it was already centered. I hope someone who knows a formula for that would come around. And I would think that you could have an infinite number of points to make the system infinitely more accurate. 360 points on the line would be one at every degree, but whats to say you couldn't have one at every .5 degree?


None

ilikerps

Reply To Post Reply & Quote

Posted at: 10/27/05 05:29 PM

ilikerps NEUTRAL LEVEL 07

Sign-Up: 10/23/03

Posts: 43

I think I found an answer! I wrote a program a while back in C++ that makes a shape based on a length and number of points. The side length uses a radius, so if I get rid of the length part and just use the radius, it would give me points based on a radius. I could just copy that formula and have it compare each point that it would normally draw.

(By the way, this is the code:)
float pi = 3.14159265358979;
for(t = sides; t > 0; t--){
thetaNums[t-1] = 2 * t * pi / sides;
}

theta = pi / sides;
radius = length * (sin((pi / 2) - theta));
radius /= sin(theta * 2);

for(t = 0; t < sides; t++){
xPts[t] = xinit + radius * cos(thetaNums[t]);
yPts[t] = yinit + radius * sin(thetaNums[t]);
}

That won't draw it, but it will get all the points needed. I plan to make the points specifically something like 15 until I find that is too few or something :)
Thanks for the idea to draw points on a circle, that reminded me of this C++ program that did just that, just not showing the circle.


None

ilikerps

Reply To Post Reply & Quote

Posted at: 10/27/05 06:13 PM

ilikerps NEUTRAL LEVEL 07

Sign-Up: 10/23/03

Posts: 43

Alright, this makes absolutely no sense. Here is what my code does in concept:

// On the parent timeline
var dead = false;

onClipEvent(enterFrame){
if(!_parent.dead){
for(t = 5; t > 0; t --){
// There is a bit of code here...
}

for(t = 0; t < _root.numPoints; t ++){
_parent.dead = true;
}

if(_parent.dead){
trace("This runs");
}
}
}

The thing is, that the "if(_parent.dead)" at the end thing is true. However, the "if(!_parent.dead)" at the beginning repeatedly is true. This is a contradiction, because the program just said that the variable is both true and false at the same time! I did a "trace()" and found that the variable is not saw as "undefined", either. Just true inside the thing and false after running, but it is not declared in the loop!


All times are Eastern Standard Time (GMT -5) | Current Time: 11:45 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!