this.addEventListener("tick", moveHorizontal.bind(this));
function moveHorizontal(evt) {
/*panzer Bewegung*/
var p = this.globalToLocal(this.stage.mouseX, this.stage.mouseY)
this.panzer.x = p.x;
/*Rakete*/
if (this.rocket.x < 560) {
this.rocket.x += 6;
} else {
this.rocket.x = -20;
this.rocket.gotoAndStop(0);
this.rocket.y = Math.random() * 200 + 30;
}
}
this.stage.addEventListener("mousedown", trigger.bind(this));
function trigger(evt) {
this.bullet.x = this.panzer.x;
this.bullet.y = 320;
this.bullet.addEventListener("tick", shoot.bind(this));
}
function shoot(evt) {
var child = this.bullet.getChildAt(0);
//var pt = child.globalToLocal(this.rocket.x, this.rocket.y);
var pt = this.rocket.localToLocal(0, 0, this.bullet);
if (stage.mouseInBounds && this.rocket.hitTest(pt.x, pt.y)) {
this.rocket.play();
evt.remove();
this.bullet.y = -20;
}
if (this.bullet.y > -10) {
this.bullet.y -= 10;
} else {
evt.remove();
}
}