We are very reluctant to add these types of API functions when the same can be achieved using go.animate(). Every additional API function increases the engine size a little bit. Each API function also means more to maintain. More to document. More to consider when making changes.
A generic go.animate() to animate component properties is almost as good or perhaps even better than specific functions. Less code. A single API to learn.
The same goes for go.get() and go.set() compared to specific functions.
I got it working now.
I do need to find a better sound
local function engine (a, self)
--print(self.esound)
if a == "on" and self.esound == false then
local url = "sounds#engine"
local duration = 0.1
go.set(url, "gain", 0.3)
sound.play(url)
--go.animate(url, "gain", go.PLAYBACK_ONCE_FORWARD, 0.3, go.EASING_INOUTSINE, duration)
self.esound = true
end
if a == "off" and self.esound == true then
local url = "sounds#engine"
local duration = 0.5
go.animate(url, "gain", go.PLAYBACK_ONCE_FORWARD, 0.0, go.EASING_INOUTSINE, duration)
timer.delay(0.5, false,function() self.esound = false, sound.stop("/sounds#engine") end)
end