Trying to figure out the best way to perform a hit test on some randomly moving objects...
I've got a Main class that creates 2 squares and 2 circles and adds them to the stage:
Within the Circle and Square classes, I've got random movement but I need to be able to figure out when a circle touches another circle and when it touches a square and can't figure out how to get that into my other classes...Code:package { import flash.display.MovieClip; public class Main extends MovieClip { public function Main() { Populate(); } private function Populate() { var circle1:Circle = new Circle; this.addChild(circle1); circle1.x = 5; circle1.y = 5; var circle2:NewCat = new Circle; this.addChild(circle2); circle2.x = 25; circle2.y = 25; var square1:Square= new Square; this.addChild(square1); square1.x = 15; square1.y = 15; var square2:Square= new Square; this.addChild(square2); square2.x = 50; square2.y = 50; } } }
I've tried using hitTestObject to test the class of the objects using getClassObj(this) but it doesn't work. I tried looping through all the children, but it hits the Main container and doesn't detect any children collisions.
Any help would be greatly appreciated!!
![]()




Reply With Quote