Laser = Melon.me.Entity.extend({
init : function (x, y) {
this._super(Melon.me.Entity, "init", [x, y, { width: 5, height: 28 }]);
this.z = 5;
this.body.setVelocity(0, 300);
this.body.collisionType = Melon.me.collision.types.PROJECTILE_OBJECT;
this.renderable = new (Melon.me.Renderable.extend({
init : function () {
this._super(Melon.me.Renderable, "init", [0, 0, 5, 28]);
},
destroy : function () {},
draw : function (renderer) {
var color = renderer.getColor();
renderer.setColor('#5EFF7E');
renderer.fillRect(0, 0, 5, 28);
renderer.setColor(color);
}
}));
this.alwaysUpdate = true;
},
update : function (time) {
this.body.vel.y -= this.body.accel.y * time / 1000;
if (this.pos.y + this.height <= 0) {
Melon.me.game.world.removeChild(this);
}
this.body.update();
Melon.me.collision.check(this);
return true;
},
onCollision : function (res, other) {
if (other.body.collisionType === Melon.me.collision.types.ENEMY_OBJECT) {
Melon.me.game.world.removeChild(this);
Melon.me.game.getParentContainer(other).removeChild(other)
return false;
}
}
});