javascript draw loop code example
Example 1: javascript game loop
function loop() {
//Game logic here
requestAnimationFrame(loop);
}
loop();
Example 2: playSound in draw loop javascript
createjs.Sound.on("fileload", handleLoad);createjs.Sound.registerSound("sounds/youraudio.mp3", "myID", 3); function handleLoad(event) { createjs.Sound.play("myID"); // store off AbstractSoundInstance for controlling var myInstance = createjs.Sound.play("myID", {interrupt: createjs.Sound.INTERRUPT_ANY, loop:-1}); }