Hi, I’m new Lua/Defold game developer coming from C#/Unity.
I’m testing music player for my game and ran into a problem I cant seem to figure out.
When track is done playing the [complete_function] is called and next track starts playing fine.
But when I manually press next track button it goes through the tracks instantly and really fast.
Help would be much appreciated!
Below is parts of the code
-- Music playback status table
local music = {
playing = true,
repeating = false,
shuffle = false,
index = nil,
}
-- Track component table
local track = {}
for i = 1, 8 do
track[i] = "#track_" .. i
end
-- Next track
local function forward()
if music.index < #track then
sound.stop(track[music.index])
music.index = music.index + 1
sound.play(track[music.index], nil, forward)
music.playing = true
else
sound.stop(track[music.index])
music.index = 1
sound.play(track[music.index], nil, forward)
music.playing = true
end
end