Rectangle-rectangle collisions are performed by cross-checking each line segment algebraically, (the way you would solve linear systems in your math class), with the extra step of making sure that the intersection of the two lines lies on the segment.
Rectangle-circle collisions are more difficult, and done by finding the intersection between each segment on the rectangle with the line perpendicular to that segment and passing through the center of the circle, then checking if the point lies within the circle. (If the distance between the point and the center of the circle is less than the circle's radius)
Remember that collision detection and collision reaction are two completely different operations, the latter being the more complicated of the two.
I think I know what you're trying to do, Oseb, but if you want to detect collision between the object and the coordinate (200,200), then you need to remove the _root._x=
Just have this as you're code: onClipEvent(enterFrame){ if(this.hitTest(200,200,true)){ this._y-=5 }
I think that this code was ok but i need it without x coordinate. But when i deleted the X coordinate (the first 200) then it didnt work.
No, you would again be checking collision between symbol/symbol, which would not be a perfect collision, but a collision between bounding boxes. If you want to detect the corners of your circle, these are your points, in order clockwise starting from the top-left (_x means circle._x, _y means circle._y)
But the only problem is that this is one point i want that if my circle reach Y = 200 then he stops thats all i want to do. But when i delet the first 200 of the code then its wont work, so how scould this code sounds?
And if yes i still have one last problem, that when he reach 200 he will bounce and bounce back (if i hold the down arrow button). And what i want is that when my character reach Y=200 then he stops and doesn't bounce back. I swear its my last question.
Actually, you don't need the hitTest function at all in this case. I assume that you are placing the code to move the character after the code to detect if the player is below the point.
Thanks! You are pretty good in AS2. That technic is good for walls but nt good for moving objects what about them? Thanks Again you really helped me a lot!
I have two more questions. 1) how to make moving wall, i mean my main character hits the moving object. Here i think those coordinates dont work.
2) arobegamr you said this code. if(this._y>200){ this._y=200 } But this code makes that my charecter stops at y=200 but i want that my character stops when Y=200 X>100 X<200? I tryed it many ways and i couldnt find the good code.