Link to home
Start Free TrialLog in
Avatar of nurbek
nurbek

asked on

polygonal shape collision detection

Hi All,


I got a road movie clip,
and there are many movie clips  (abstackles on the road)

there ara different shapes movieclips on the background, (trees, stones etc ... these are stable)  (1.layer)
I added 2.layer, and put the small rectangular movie clip (piece) in order to check the collision

I got this code to check the collision,

and as the pieces movieclips increses it runs slowly

------------------
      for (piece in _root.road) {
            if (car.hitTest(_root.road[piece])) {
                  speed = 0;
                  car_hit = true;
                  break;
            }
      }
-----------------

Is there easier way?
Can we check the collisions polygonal shapes?

thanks,
Nurbek
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nurbek
nurbek

ASKER

thanks for giving the link,

It works, but it also slows down, uses more memory,

I solved it using my code, I splitted the movieclip into small parts, as the car moves it gets the name of the movieclips(road) that the car over on it ,

and loop inside only that movie, (before I was looping through all movieclips)

regards,