this.update();
RAF(function(){
_this.loop();
})
},
start:function(){
this.init();
this.loop();
}
}
window.RAF = (function(){
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {window.setTimeout(callback, 1000 / 60); };
})();
return Game;
}();
function getRandom(a , b){
return Math.random()*(b-a)+a;
}
window.onload = function(){
testBox.start();
}
</script>
</body>
</html>
离屏canvas还有一个注意事项,如果你做的效果是会将对象不停地创建和销毁,请慎重使用离屏canvas,至少不要像我上面写的那样给每个对象的属性绑定离屏canvas。









