var?Shooter?=?cc.Sprite.extend({
speed:?100,
HP:?5,
layer:?null,
ctor:?function(layer,?x,?y)?{
this._super("#ship03.png");
this.tag?=?this.zOrder;
this.x?=?x;
this.y?=?y;
this.scale?=?1;
this.layer?=?layer;
this.shootBullet(this.x,?this.y);
this.addMouse();
},
addMouse:?function()?{
var?that?=?this;?//緩存this指針
if?('mouse'?in?cc.sys.capabilities)?{
cc.eventManager.addListener({
event:?cc.EventListener.MOUSE,
onMouseDown:?function(event)?{
cc.log("shoot?MOUSE?DOWN?EVENT");
that.shootBullet(that.x,?that.y);
},
onMouseUp:?function(event)?{
cc.log("shoot?MOUSE?UP?EVENT");
}
},?that);
cc.log("ADD?shoot?MOUSE");
}?else?{
cc.log("MOUSE?Not?supported");
}
},
//添加子彈,並且向上移動;
shootBullet:?function(x,?y)?{
cc.log("Bullet?shooted");
var?Bullet?=?new?Bullets(x,?y);
Bullet.setTag(1);
Bullet.Move();
Bullet.setTag(6);
this.layer.addChild(Bullet,?2);
this.layer._bullets.push(Bullet);
GC.FILE?=?false;
}
});