當前位置:編程學習大全網 - 網站源碼 - js cocos 中鼠標點擊事件調用其它方法出錯, uncaught typeerror: undefined is not a function

js cocos 中鼠標點擊事件調用其它方法出錯, uncaught typeerror: undefined is not a function

/**

*?Created?by?Administrator?on?2014/9/30.

*/

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;

}

});

  • 上一篇:手機經常自動閃退。
  • 下一篇:找壹個簡單的屏蔽IP的php代碼。
  • copyright 2024編程學習大全網