//本意是触模屏幕时,添加一个精灵,程序能在android 正常运行,就是触摸时不能添加精灵,即好象触摸没有触发,请高手指点一下
var CsLayer = cc.LayerColor.extend({
ctor:function(){
this._super(cc.color(0,0,255));
if( ‘touches’ in cc.sys.capabilities ) {
// this is the default behavior. No need to set it explicitly.
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches:true,
onTouchesBegan: this.onTouchesBegan,
onTouchesMoved: this.onTouchesMoved
}, this);
} else {
var cs = new cc.Sprite(res.apple1);
cs.setPosition(100,200);
this.addChild(cs);
cc.log(“TOUCHES not supported”);
}
},
onTouchesBegan:function(touches, event) {
var targe = event.getCurrentTarget();
var cs = new cc.Sprite(res.apple1);
cs.setPosition(200, 200)
this.addChild(cs);
//不管用下面哪一个都无效
//self.addChild(cs);
//target.addChild(cs);
//return true;
},
onTouchesMoved:function(touches, event) {
cc.log("TOUCHES move");
}
});
var CsScen = cc.Scene.extend({
onEnter:function(){
this._super();
var bgLay = new CsLayer();
this.addChild(bgLay);
//this.addChild(aniLay);
}
});