View Full Version : Hit Test problem
Psykloak1
May 25th, 2002, 01:52 PM
Pom tried this and couldn't get it working, I wanna get some more opinions:
I'll try to explain it as best I can. I have a movie clip of a long bar shape that spins. I programed it to move up down left and right when the correct arrow keys are pressed.
Then I have anohter movie clip that dosent move. I tried to use Hit test to make it tell me when the two touch. The problem is that it works too good. It says its touching when the bar gets close and when it really is covering.
OK, i know this is really confusing, thats why I uploaded the FLA for any one who wants to help.
http://www.angelfire.com/pokemon2/onlinepics/spin.html
ilyaslamasse
May 25th, 2002, 02:00 PM
I tried to do it, and it's a real pain in the ***. Moreover, there's no Shape flag when you do it like this, so I think the best solution is to create your own hitTest function. Easy. :D
pom 0]
ilyaslamasse
May 25th, 2002, 02:44 PM
I can't get it to work. Pisses me off.
pom 0]
ilyaslamasse
May 25th, 2002, 02:54 PM
Closest I could get :in the first frame
MovieClip.prototype.hitTest2 = function (largeur) {
        var distx = _root.circle._x - this._x ;
        var disty = _root.circle._y - this._y ;
        var distance = Math.sqrt(distx*distx+disty*disty);
        var angle = Math.atan2(disty,distx) ; //angle in radians
        angle *= 180/Math.PI ; //angle in degrees
        trace (distance - _root.circle._width/2 > largeur) ;
        if (distance - _root.circle._width/2 > largeur) {
                _root.texte = "No collision";
        } else {
                a = this._rotation>angle-_root.circle._width/distance*180/Math.PI ;
                b = this._rotation<angle+_root.circle._width/largeur*180/Math.PI ;
                c = this._rotation-180<angle+_root.circle._width/largeur*180/Math.PI ;
                d = this._rotation+180>angle-_root.circle._width/largeur*180/Math.PI
                if (a and b and c and d){
                                _root.texte = "Collision" ;
                }
                else {
                        _root.texte = "No collision";
                }
        }
}on the Line movie clip (has to be FLAT !!)
onClipEvent (load) {
        // the line has to be flat !!
        large = this._width;
}
onClipEvent (enterFrame) {
        _rotation+=1 ;
        this.hitTest2(large);
}This code slows my computer, so you better have a good computer.
pom 0]
Psykloak1
May 25th, 2002, 03:15 PM
Maybe this will help.
media.nintendo.com/ninten..._mov01.wmv (http://media.nintendo.com/nintendo/contents/gamepage/gamecontent/images/e3/kururin_paradise/e3_kururin_agb_mov01.wmv)
that link is to a movie file of a GBA video game that im trying to clone
heres a link to it's main page
nintendo.com/games/gamepa...9&showMe=1 (http://nintendo.com/games/gamepage/gamepage_main.jsp?gameId=1279&showMe=1)
Iammontoya
May 25th, 2002, 07:22 PM
didnt work for me using either. (I just tried for grins)
Psykloak1
May 26th, 2002, 05:14 AM
Here are links to 2 other flash forums that are working on it, se if what they've done helps at all
www.were-here.com/forums/...post896780 (http://www.were-here.com/forums/showthread.php?s=&postid=896780#post896780)
flashmove.com/board/showt...eadid=7276 (http://flashmove.com/board/showthread.php?s=cd8ff3ced13f2a85e88376501e7749f5&threadid=7276)
Psykloak1
May 26th, 2002, 05:43 AM
ok, the link i posted above dosent work so try this
www.angelfire.com/pokemon.../spin.html (http://www.angelfire.com/pokemon2/onlinepics/spin.html)
and pom, try this,
www.angelfire.com/pokemon...spin2.html (http://www.angelfire.com/pokemon2/onlinepics/spin2.html)
^ goto this page ^
try to make it so the hit tests works between the bar and the circle, not the black box (you'll see what I mean if you goto that second link and d/l it)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.