polygonal shape collision detection

Posted on 2006-04-07
Last Modified: 2008-01-16
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;

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

Question by:nurbek
    LVL 34

    Accepted Solution

    You can calculate the hitTest at pixel level in Flash 8, using BitmapData.hitTest

    here is a sample with source FIle

    I feel this is what you want...

    : - Aneesh
    LVL 13

    Author Comment

    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)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now