Hey everyone,
In my platform game my character shoots bullets from a gun, these bullets are loaded from a ‘bullet’ class. A new instance of this class has the variable name ‘bulletVar’. I can adjust the bullets x and y position like so:
bulletVar.x = 253;
But I also want to use it in a hitTestObject, I thought that the following code would work, but it does not!
stage.addEventListener(Event.ENTER_FRAME, hitEnemy);
function hitEnemy(event:Event):void
{
if (bulletVar.hitTestObject(enemy_mc))
{
enemy_mc.gotoAndStop(“dead”);
stage.removeEventListener(Event.ENTER_FRAME, hitEnemy);
}
}
Also - how would I then remove that hitting bullet from the movie?
Here’s my code to call a bullet:
var bulletVar:bullet = new bullet();
this.addChild(bulletVar);
Thanks a lot,
Ryan