一个音效在手机浏览器上多次播放后就会失灵,但我在chrome上测试没有任何问题。手机是魅族MX2,音效文件是mp3,在微信浏览器失灵
cc.audioEngine.playEffect(res.audio, false);
一个音效在手机浏览器上多次播放后就会失灵,但我在chrome上测试没有任何问题。手机是魅族MX2,音效文件是mp3,在微信浏览器失灵
cc.audioEngine.playEffect(res.audio, false);
我做了一个test,简化了代码,问题同样存在,下面是代码
var TestLayer = cc.Layer.extend({
pig:null,
hand:null,
utime:0,
ntime:0,
sumhit:0,
labeltime:null,
ctor:function () {
this._super();
var size = cc.winSize;
var background =new cc.Sprite(res.background);
background.x=size.width/2;
background.y=size.height/2;
this.addChild(background,0);
this.pig =new cc.Sprite(res.pig1);
this.pig.x=g_setting.pigx;
this.pig.y=g_setting.pigy;
this.pig.anchorX=0.5;
this.pig.anchorY=0.3;
this.addChild(this.pig,10);
this.labeltime = new cc.LabelTTF("10", "Arial", 70);
this.labeltime.x = size.width / 2;
this.labeltime.y = 650;
this.labeltime.color= new cc.color(206,42,208);
this.addChild(this.labeltime, 5);
var listener1 = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
onTouchBegan : function(touch,event){
var target = event.getCurrentTarget();
target.rotatepig();
cc.audioEngine.playEffect(res.audio, false);
return true;
}
});
cc.eventManager.addListener(listener1, this);
},
rotatepig : function(){
//cc.audioEngine.stopEffect(res.audio);
//cc.audioEngine.playEffect(res.audio, false);
this.ntime+=1;
this.labeltime.setString(this.ntime);
}
});
var TestScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new TestLayer();
this.addChild(layer);
}
});