mtEverest
12-16-2008, 04:41 AM
I'm stuck getting collision detection to work on a simple shooter game.
Currently, you can click on the "enemy" to make the "Die" code run(nested in the "Monster" movieclip). I want to change it so you can press the space bar to shoot water splashes that act on the "enemies" (just funny ball shapes for now). Got that to work, but can't figure out how to pass the "Monster" movieclip into the Water class file to get the collision detection to work between the "Water" splashes and the dynamically generated "Monster".
FLA and class files attached. Many thanks...
// This function is on the main timeline
function shootWatergun(event:Event):void
{
var water:MovieClip;
if(keyPressed == Keyboard.SPACE && spaceIsDown == false)
{ // Monster is passed into a separate class "Water"
// Monster is a movieclip animated by XML
water = new Water(Monster);
water.x = waterGun_mc.x;
water.y = waterGun_mc.y;
water.rotation = waterGun_mc.rotation;
addChild(water);
spaceIsDown = true;
}
Currently, you can click on the "enemy" to make the "Die" code run(nested in the "Monster" movieclip). I want to change it so you can press the space bar to shoot water splashes that act on the "enemies" (just funny ball shapes for now). Got that to work, but can't figure out how to pass the "Monster" movieclip into the Water class file to get the collision detection to work between the "Water" splashes and the dynamically generated "Monster".
FLA and class files attached. Many thanks...
// This function is on the main timeline
function shootWatergun(event:Event):void
{
var water:MovieClip;
if(keyPressed == Keyboard.SPACE && spaceIsDown == false)
{ // Monster is passed into a separate class "Water"
// Monster is a movieclip animated by XML
water = new Water(Monster);
water.x = waterGun_mc.x;
water.y = waterGun_mc.y;
water.rotation = waterGun_mc.rotation;
addChild(water);
spaceIsDown = true;
}