Forum Topic: need help with shape flag hittests

(55 views • 1 reply)

This topic is 1 page long.

<< < > >>
None

SAGGAMES

Reply To Post Reply & Quote

Posted at: 8/15/08 09:17 AM

SAGGAMES DARK LEVEL 06

Sign-Up: 08/10/08

Posts: 58

I need to know how to do advanced hittests, ones that do use the shape flag of the object, because for my next game I have some rather large circles, but the script uses them like squares... before calling me an AS noob, please look at the game I published at http://www.newgrounds.com/portal/view/45 3356


None

LonLonRanch

Reply To Post Reply & Quote

Posted at: 8/15/08 09:56 AM

LonLonRanch LIGHT LEVEL 17

Sign-Up: 05/22/05

Posts: 320

well what the shapeFlag hitTest does is it gives you an x and y value to check for hitTest, rather than a hitBox

MovieClip.hitTest( x, y, shapeFlag);

But when dealing with circles (which yes gets complicated, and I actually have never done this before)
you would have to do something like this:

object1.hitTest( (object2._x - object2_radius), (object2._y - object2_radius), true);

Now this code wouldn't work in a million years if you tried it of course but its an example. You need to have a code that gets the distance between the 2 objects that are going to collide. Then when that distance is, say, the distance of the radius of both of the 2 objects (say each circle is 20 wide, or radius of 10, then that distance would need to be 20) Then you do you're execution.

Again, I hope this helps, it is a bit confusing I might not have explained it perfectly but its headed in the right direction. Good Luck :D


All times are Eastern Standard Time (GMT -5) | Current Time: 02:08 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!