[AS3] Having trouble with bullets and enemies
Hello, I was wondering if any of you could clear up a really big confusion I'm having. I simply want to have a player be able to shoot bullets at randomly spawning enemies. I havent been able to do this in days, so I'm finally asking for help.
Everything occurs in my .as file called PlayScreen. PlayScreen creates the player, asteroids, and bullets. My first approach was to create two Arrays in PlayScreen, one for bullets and one for enemies. Then addChild(enemy) and add the enemy object to the Array. Same with the bullets for when you shoot. But I wasn't able to get the hitTesting right, I kept getting errors and didn't understand how to tell a certain asteroid to explode when it gets hit by the bullet.
My second approach was to create a bulletContainer movieclip class in PlayScreen, and do bulletContainer.addChild(bullet), while having enemies appear in PlayScreen. But it seems I'd have to go into the enemy class and try to hitTest it againt the bulletContainer, but I don't understand how to access the bulletContainer class from the enemy class. I thought making it public static var would work, but it doesn't.
How do you access non-static variables in one class from other classes?