Skip to main content
February 6, 2007
Question

colision detector problem

  • February 6, 2007
  • 6 replies
  • 354 views
I have a small animated ball (3px) that roll around the stage. Also, I have a wall (thin line 1px) on the stage. I am trying to detect colision between the ball and the wall. Every EnterFrame I am checking for hitTest. The problem is that the ball is very small and the wall is very thin so sometimes the ball doesnt colide with the wall. it just skip it. Any solution???
This topic has been closed for replies.

6 replies

kglad
Community Expert
Community Expert
February 7, 2007
you should have only one loop to update the 25 balls position. and you should consider enabling the cacheAsBitmap property of the 25 balls.
Inspiring
February 7, 2007
If you wanna do the math, take a look at:

http://www.tonypa.pri.ee/

which has a tut on vecor based movement and collision detection.

Manno

shikozel wrote:
> Thanks kglad. yea. I was thinking about this solution but I thought it might be too much of cpu process ( I have 25 balls on the screen) but it might be the only solution. Thanks again

--
----------
Manno Bult
http://www.aloft.nl
manno@xs4all.nl
February 7, 2007
Thanks kglad. yea. I was thinking about this solution but I thought it might be too much of cpu process ( I have 25 balls on the screen) but it might be the only solution. Thanks again
kglad
Community Expert
Community Expert
February 7, 2007
don't use an onEnterFrame handler or timeline tween to move the ball. use setInterval() with a high enough frequency of calls that the movements per interval don't allow your ball to go past the wall without intersecting it. use the same loop to check the hitTest().
February 7, 2007
the hitTest detect the colusion between the ball and the wall. I cant build thick trnsparent wall becasue if the wall place horizontal, the ball should not colide with the wall when moving from left to right. I hope I am clear
Inspiring
February 6, 2007
What is the hitTest for? It's for stopping the ball or for bouncing?
If the ball doesn't have to go trough the wall, just build a transparent wall, wider than the thin line.