Reply To: About timeouts

PennController for IBEX Forums Support About timeouts Reply To: About timeouts

#10809
Larissa_Cury
Participant

Hi, @Jeremy ! What is the best way to get the same effect (play the click sound when a button is clicked) using a selector? Like this:

I tried to use a .callback as well, but it didn’t work…With the code below, sometimes it works, sometimes it doesn’t (the audio is just an effect of a click)


newImage("mainImage", row.image)
  .css({
  "display": "block",
  "position": "fixed",
  "top": "35vh", // 50% of the viewport height
  "left": '50%', // Use 50% for horizontal centering and 15% and 85% left/right
  "transform": "translate(-50%, -50%)",
 //  "width": "25em", // Replace with the desired width of the image in em units
 // "height": "25em", // Replace with the desired height of the image in em units
  "z-index": "9999", // To make sure the image is on top of other elements
})
.print()
,
newAudio('keyPressAudio', "keyPress1.mp3")
,
 newSelector("position")
,
  newCanvas("buttons",1180,100)
  .add("center at 10%", "bottom at 100%", newButton("btn--1", "1").selector("position"))
  .add("center at 30%", "bottom at 100%", newButton("btn--2", "2").selector("position"))
  .add("center at 50%", "bottom at 100%", newButton("btn--3", "3").selector("position"))
  .add("center at 70%", "bottom at 100%", newButton("btn--4", "4").selector("position"))
  .add("center at 90%", "bottom at 100%", newButton("btn--5", "5").selector("position"))
  .css({
      "top": "40vh"
  })
  .center()
  .print()
    ,
    getSelector("position")
      .once()
      .wait()
      .log()
    ,
    getAudio('keyPressAudio').play()
)
 // .log("item", row.imageAudio)
  .log('image', row.image)
  .log("correctKey", row.correctKey)
);