run(){
if(!this.isGameOver){
this.dataStore.get('background').draw();
const pencils = this.dataStore.get('pencils');
if (pencils[0].x + pencils[0].width <= 0 && pencils.length === 4) {
pencils.shift();
pencils.shift();
this.dataStore.get("score").isScore = true;
}
if (pencils[0].x <= (DataStore.getInstance().canvas.width - pencils[0].width) / 2 && pencils.length === 2) {
this.createPencil();
}
this.dataStore.get('pencils').forEach(function (value) {
value.draw();
})
this.dataStore.get('land').draw();
this.dataStore.get('score').draw();
this.dataStore.get('birds').draw();
let timer = requestAnimationFrame(() => this.run());
this.dataStore.put('timer', timer);
}else{
cancelAnimationFrame(this.dataStore.get('timer'));
this.dataStore.get('startButton').draw();
this.dataStore.destroy();
console.log('123');
wx.triggerGC();
}
}
请看加大字体内容
requestAnimationFrame绘制后,cancelAnimationFrame停止绘制。再把this.dataStore.get('startButton').draw();绘制上去。苹果iphone7显示正常。华为荣耀V10只显示停止后的图片。