A simple Transition Manager that pauses and resumes transitions

Hello,
here go a simple transition manager that I developed.
It helps when I need pause my game

CODE:
[lua]local TransitionManager = {}

–TRANSITION MANAGER CLASS
TransitionManager.new = function()
local transitionManager = {}
transitionManager.transitions = {}

function transitionManager:to(object, param)
local transition = transition.to(object, param)
transition.isPaused = false
table.insert(self.transitions, transition)
end

function transitionManager:from(object, param)
local transition = transition.from(object, param)
transition.isPaused = false
table.insert(self.transitions, transition)
end

function transitionManager:update()
if table.maxn(self.transitions) > 0 then
for index, value in pairs(self.transitions) do
if (value._timeStart + value._duration < system.getTimer() and value.isPaused == false) then
table.remove(self.transitions, index)
value = nil
end
end
end
end

function transitionManager:pause()
if table.maxn(self.transitions) > 0 then
for index, value in pairs(self.transitions) do
value.isPaused = true
value.timePause = system.getTimer()
transition.cancel(value)
end
end
end

function transitionManager:resume()
if table.maxn(self.transitions) > 0 then
for index, value in pairs(self.transitions) do
local param = value._keysFinish
param.time = value._duration - (value.timePause - value._timeStart)
local transition = transition.to(value._target, param)
transition.isPaused = false
self.transitions[index] = transition
end
end
end

return transitionManager
end[/lua]

USAGE:
[lua]local isPaused = false
local transitionManager = TransitionManager.new()

local circle = display.newCircle(100,100, 40)
local rect = display.newRect(10,10, 40, 40)
local function pause()
if isPaused then
isPaused = false
transitionManager:resume()
else
isPaused = true
transitionManager:pause()
end
end
Runtime:addEventListener(‘tap’, pause)
transitionManager:to(circle, {time = 3000, x = 400, y = 300})
transitionManager:from(rect, {time = 5000, alpha = 0, x = 400, y = 300})[/lua] [import]uid: 194543 topic_id: 35372 reply_id: 335372[/import]

–Edit
Added transitionManager:from [import]uid: 194543 topic_id: 35372 reply_id: 140807[/import]

–Edit
Added transitionManager:from [import]uid: 194543 topic_id: 35372 reply_id: 140807[/import]

Very nice!

I have a question though is _timeStart an api?  I can’t seem to find anything about it anywhere.  I’m trying to design my own transition manager so I need to know how to it all works.  Thanks

Also I guess here is where I’m struggling I’m also trying to design a Timer Manager and when I try to apply the same logic to timers ie print(value._timeStart) --for a timer.performWithDelay it returns a nil value, however when I use that bit of code on a transition it returns a value.

Very nice!

I have a question though is _timeStart an api?  I can’t seem to find anything about it anywhere.  I’m trying to design my own transition manager so I need to know how to it all works.  Thanks

Also I guess here is where I’m struggling I’m also trying to design a Timer Manager and when I try to apply the same logic to timers ie print(value._timeStart) --for a timer.performWithDelay it returns a nil value, however when I use that bit of code on a transition it returns a value.