Hi there!
I’m using Zapworks Studio to create an animated Traking Image experience, with music. I have the 3D model with the animation and music in a scene that is working.
My next step is create a button from a PNG that restart both things (animation and music) when you press it.
I’ve read in https://docs.zap.works/studio/audio-and-video/filetype-support/ that I can loop the music by calling the restart()
function on them when the finish
event is fired.
My current script in the root (wich plays the music) is:
var myaudio = Z.Audio(“Song.ogg”);
myaudio.start();
I added the PNG button to the scene, then I right-click on it, and select> New>Script>PointerDown, and added the next script on it:
parent.on(“pointerdown”
var myaudio = Z.Audio(“Song.ogg”);
myaudio.restart();
}
Now the button is pressable, but it starts the song again while the first one is sounding yet, so the result is the song playing in 2 instances at the same time, what I need is stop the song and restart it, but I can’t find any command that makes the song end and restart.
I tried some commands also to make the animation restart when I press the button, but I didn´t find a solution.
Can you help me, please?
Thank you so much ^^