Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

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
0
nurbek
Asked:
nurbek
1 Solution
 
Aneesh ChopraCommented:
You can calculate the hitTest at pixel level in Flash 8, using BitmapData.hitTest

here is a sample with source FIle
http://www.gskinner.com/blog/archives/2005/08/flash_8_shape_b.html

I feel this is what you want...

: - Aneesh
0
 
nurbekAuthor Commented:
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,
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now