PDA

View Full Version : Hit test with wierd shapes


Kelna
05-12-2005, 10:30 PM
hey, i'm making a little project and i have a character that moves around and what i want to happen is when he hits an enemy (movie clip) he moves back to start. I know how to do hit tests, but it only works for rectangles. so how would i make a hit test for something that is not a rectangle?

thx for the help.

Kelna
05-15-2005, 01:22 AM
Plz this is important, im trying to make a simple game for a school project, and I really only need to know how to make hittests with non rectanglar movie clips. I'll post hte .fla too.

cxn926
05-15-2005, 01:28 AM
i did not look at the file but i remember this it is as if you have the instance name of person.
onClipEvent (enterFrame) {
if (_root.person.hitTest(_root.player_mc)) {
_root.gotoAndStop("framelabel")
}
}

that is just a guesse.
tell me if it works

Kelna
05-15-2005, 08:10 PM
that only works on rectanglar shapes (and yes i tested it).

cxn926
05-15-2005, 10:34 PM
weird. my shape is a bomb and it works.

AZmoon
05-16-2005, 01:17 AM
I duno, I'd have to see cxn926's bomb.
For me I also need to know this, but so far when I draw my target's/objects and convert them to sysmbols, it draws a rectanglar box around the image. eg, I draw a circle it will draw a box around it, and the hit test will still register a hit if its within the rectanglar box (even if its not on the circle symbol)

:edit:
if (hitTest(_x,_y, true)) {
this.hitTest(_root.thing);
_x=50;
_y=50;
}
btw this coding is flawed...

The way I am thinking of is using a mask

Kelna
05-16-2005, 03:16 AM
i know the code is flawed, i have been seeing that code on the forums, so i have been trying to change that code to fit my project, but whne it doesnt work i just edit undo back to that code so i can try again.

Kelna
05-16-2005, 04:19 PM
please some reply with the answer i need this code to continue with my work that will be due in a few days.

AZmoon
05-17-2005, 03:15 AM
A quick fix would be to divide the large object into smaller objects...?

Kelna
05-17-2005, 01:32 PM
doing that would take a looong time, but it is a option, but i would really like to be able to do it with one line of code insted of doing like 20.

AZmoon
05-18-2005, 01:35 AM
1)spend 1 day writing out alot of code to achive your desired effect
vs
2)spend weeks asking on forums and wasting time waiting for peopel to reply

(I am only sayng this because you mentioned your work is due in a few days. I tend to go with "whatever works" solutions in these cases :p )

Kelna
05-18-2005, 10:29 PM
yeah i know, but i still would liek to know how to do it.