Browse Source

less yuge change

master
mortie 7 years ago
parent
commit
88f12d7c48
2 changed files with 3 additions and 7 deletions
  1. 3
    2
      js/assets.js
  2. 0
    5
      js/script.js

+ 3
- 2
js/assets.js View File

@@ -25,6 +25,9 @@ function AudioSource(src, ext) {
this.ready = false;

this.audio.addEventListener("canplaythrough", function() {
if (this.ready)
return;

this.ready = true;
this.emit("load");
}.bind(this));
@@ -56,8 +59,6 @@ function ImageSource(src, frameh, ext) {
this.frameh = frameh == null ? -1 : frameh;
this.steps = 1;

console.log("image", assetsPath, assetsPath+"/images/"+src+ext);

this.img.onload = function() {
console.log(this);
this.ready = true;

+ 0
- 5
js/script.js View File

@@ -4,14 +4,12 @@ window.ontouchmove = function(evt) {

var currentSoundtrack = -1;
function playSoundtrack(tracks) {
console.log("Playing track...");
var keys = Object.keys(tracks);
if (currentSoundtrack === -1)
currentSoundtrack = randInt(0, keys.length);

var key = keys[currentSoundtrack];
var track = tracks[key];
console.log("Playing track", key);

var trackId = currentSoundtrack;
while (currentSoundtrack === trackId)
@@ -20,11 +18,8 @@ function playSoundtrack(tracks) {
if (track.ready) {
track.play();
track.once("ended", function() { playSoundtrack(tracks) });
console.log("playing immediately, as it's loaded");
} else {
console.log("loading it...");
track.once("load", function() {
console.log("loaded.");
track.play();
track.once("ended", function() { playSoundtrack(tracks) });
});

Loading…
Cancel
Save