浏览代码

Audio can be preloaded before the game begins

tags/v0.1.1
Fen Dweller 6 年前
父节点
当前提交
2f6e27bd1e
共有 4 个文件被更改,包括 14 次插入3 次删除
  1. +1
    -1
      audio.js
  2. +6
    -2
      satiate.js
  3. +3
    -0
      stories/demo.js
  4. +4
    -0
      stories/fen-snack.js

+ 1
- 1
audio.js 查看文件

@@ -226,7 +226,7 @@ function checkCache(type, name, hit, miss) {
} }
} }


function initAudio(story, state) {
function initAudio(story) {
if (!audioContext) if (!audioContext)
audioContext = new (window.AudioContext || window.webkitAudioContext)(); audioContext = new (window.AudioContext || window.webkitAudioContext)();




+ 6
- 2
satiate.js 查看文件

@@ -84,7 +84,6 @@ function init(story) {
}; };


initWorld(story, state); initWorld(story, state);
initAudio(story, state);
initGame(story, state); initGame(story, state);


story.intro.setup(state); story.intro.setup(state);
@@ -122,7 +121,12 @@ function initStart() {


holder.innerHTML = ""; holder.innerHTML = "";


const tags = stories.filter(s => s.id == [event.target.value])[0].tags;
const story = stories.filter(s => s.id == [event.target.value])[0];
const tags = story.tags;

initAudio(story);

story.preload.forEach(sound => loadAudio(sound));


tags.forEach(tag => { tags.forEach(tag => {
const div = document.createElement("div"); const div = document.createElement("div");


+ 3
- 0
stories/demo.js 查看文件

@@ -16,6 +16,9 @@ stories.push({
}, },
"sounds": [ "sounds": [
"sfx/oof.ogg" "sfx/oof.ogg"
],
"preload": [

], ],
"world": { "world": {
"Stairs": { "Stairs": {


+ 4
- 0
stories/fen-snack.js 查看文件

@@ -21,6 +21,10 @@ stories.push({
"loop/fen-intestines.ogg", "loop/fen-intestines.ogg",
"loop/fen-bowels.ogg" "loop/fen-bowels.ogg"
], ],
preload: [
"sfx/stomach-churn.ogg",
"loop/fen-stomach.ogg"
],
intro: { intro: {
start: "stomach", start: "stomach",
setup: state => { setup: state => {


正在加载...
取消
保存