it's my first question here, but I've been having this problem lately and need some help.
I'm programming a small little Android Game for the weekend and I'm having a problem with making my ship's bullets hit the enemies and both disappear...
I'll give you guys a little rundown of my code:
stage.addEventListener(Event.ENTER_FRAME, Update);
LeftButton.addEventListener(TouchEvent.TOUCH_OVER, LBOn);
LeftButton.addEventListener(TouchEvent.TOUCH_BEGIN, LBTouch);
LeftButton.addEventListener(TouchEvent.TOUCH_OUT, LBOff);
LeftButton.addEventListener(TouchEvent.TOUCH_END, LBRelease);
RightButton.addEventListener(TouchEvent.TOUCH_OVER, RBOn);
RightButton.addEventListener(TouchEvent.TOUCH_BEGIN, RBTouch);
RightButton.addEventListener(TouchEvent.TOUCH_OUT, RBOff);
RightButton.addEventListener(TouchEvent.TOUCH_END, RBRelease);
BA.addEventListener(TouchEvent.TOUCH_BEGIN, Shoot);
this is my Stage's Event Listener Block. All the current EventListeners are in this little part, pretty simple and they work okay for what I'm doing, but the last event calls the function Shoot and that's where things get tricky...
function Shoot(TouchEvent) {
SpawnBullet();
};
Ok, simple enough. Just a function that calls another function to spawn my bullets, not much harm there the way I see it...
this is how I tried to make the code run:
function SpawnBullet() {
var Bullet:Bullet1 = new Bullet1();
stage.addChild(Bullet);
Bullet.x = Player.x;
Bullet.y = Player.y - (Player.height / 2);
Bullet.addEventListener(Event.ENTER_FRAME, BulletUpdate);
function BulletUpdate(Event) {
Bullet.y -= 20;
if(Bullet.y <= 100) {
Bullet.removeEventListener(Event.ENTER_FRAME, BulletUpdate);
stage.removeChild(Bullet);
Bullet = null;
};
};
};
When I run the game i get this error:
ReferenceError: Error #1069: Property ENTER_FRAME not found on flash.events.Event and there is no default value.
at Function/Shooter_fla:MainTimeline/SpawnBullet/Shooter_fla:BulletUpdate()[Shooter_fla.MainTimeline::frame1:41]
I'm not trying to fake my skills, I think I'm not understanding how the adding and removal of childs work, and since I hate just searching the web for a way to do something without learning the way something works I came here for a bit of help. Thanks in advance for any help!