Sfoglia il codice sorgente

less yuge change

master
mortie 7 anni fa
parent
commit
88f12d7c48
2 ha cambiato i file con 3 aggiunte e 7 eliminazioni
  1. 3
    2
      js/assets.js
  2. 0
    5
      js/script.js

+ 3
- 2
js/assets.js Vedi File

this.ready = false; this.ready = false;


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

this.ready = true; this.ready = true;
this.emit("load"); this.emit("load");
}.bind(this)); }.bind(this));
this.frameh = frameh == null ? -1 : frameh; this.frameh = frameh == null ? -1 : frameh;
this.steps = 1; this.steps = 1;


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

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

+ 0
- 5
js/script.js Vedi File



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


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


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

Loading…
Annulla
Salva