Audio with Image Hover #1363
Unanswered
Kayoz1984
asked this question in
Creating games with Quest
Replies: 1 comment
-
Hello, I can probably help with the audio bits, but I don't know enough CSS to help with the images. I've got a game with a <object name="radio">
<inherit name="switchable" />
<feature_switchable />
<switchonmsg>Click. The sounds of music fill the air.</switchonmsg>
<switchoffmsg>Click. Sweet silence.</switchoffmsg>
<take />
<look>A cheap radio, currently switched {if radio.switchedon:on}{if not radio.switchedon:off}.</look>
<onswitchon type="script"><![CDATA[
JS.eval ("$('audio').remove();")
msg ("<audio id=\"radio-div\" src=\"" + GetFileURL("mister-index.ogg") + "\" autoplay loop controls></audio>")
]]></onswitchon>
<onswitchoff type="script">
JS.eval ("$('audio').remove();")
</onswitchoff>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
<value>Switch on</value>
<value>Switch off</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Switch on</value>
<value>Switch off</value>
</inventoryverbs>
</object> When turning it on, it:
JS.eval ("$('audio').remove();")
msg ("<audio id=\"radio-div\" src=\"" + GetFileURL("mister-index.ogg") + "\" autoplay loop controls></audio>") Then, I added scripts to adjust the volume when leaving/entering the room when the radio is switched on: <function name="ResumeRadioIfOn"><![CDATA[
if (radio.switchedon) {
SetTimeout (2) {
if (radio.switchedon) {
JS.eval ("$('audio').remove();")
msg ("<audio id=\"radio-div\" src=\"" + GetFileURL("mister-index.ogg") + "\" autoplay loop controls></audio>")
if (not radio.parent = game.pov and not radio.parent = game.pov.parent) {
JS.eval ("$('#radio-div')[0].volume = .25;")
}
else {
JS.eval ("$('#radio-div')[0].volume = 1;")
}
}
if (not radio.parent = game.pov and not radio.parent = game.pov.parent) {
JS.eval ("$('#radio-div')[0].volume = .25;")
}
else {
JS.eval ("$('#radio-div')[0].volume = 1;")
}
}
}
]]></function> I hope this helps a little. (Someone else will probably pop in to help with the CSS for the images.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to make two images sit on top of each other and when the player hovers over either one, a sound will play. the top image is smaller than the lower so that crossing over the area of either will generate the sound. In fact it may be worthwhile to set the volume of these sounds to zero and only after the player enters the field actually play the volume at full. Any help with this will be greatly appreciated,
Beta Was this translation helpful? Give feedback.
All reactions