Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
GTween setPaused() bug — Gideros Forum

GTween setPaused() bug

cskcsk Member
edited July 2013 in Bugs and issues
Hi there!

I found a bug in the latest version of the GTween plugin. It's a (probably unwanted) result of the "invalid key to 'next'"-bugfix discussed here: http://www.giderosmobile.com/forum/discussion/2936

If you have two tween objects,
tweenA
and
tweenB
, and
tweenA
has an (e.g. "complete") EventListener such as
function() tweenB:setPaused(true) end
, then it can happen that
tweenB
won't get paused instantly in the current tick, but only in the next tick. That means,
tweenB
can still perform an action even after the
setPaused(true)
call!

The problem lies in the
GTween.staticTick()
function:
function GTween.staticTick()
  local t = GTween.time
  GTween.time = os.timer()
  if GTween.pauseAll then
    return
  end
  local dt = (GTween.time - t) * GTween.timeScaleAll
  for tween in pairs(GTween.tickList) do
    copyTickList[#copyTickList + 1] = tween
  end
  for i=1,#copyTickList do
    local tween = copyTickList[i]
    tween:setPosition(tween._position + (tween.useFrames and GTween.timeScaleAll or dt) * tween.timeScale)
  end
  for i=#copyTickList,1,-1 do
    copyTickList[i] = nil
  end
end
All currently unpaused tweens are put into
copyTickList
before
tween:setPosition()
is called, but if one of those tweens gets paused within a
setPosition()
call, the
setPosition()
function will still be called on those paused tweens!

A simple fix for this bug would be to alter the line:
if not tween._paused then tween:setPosition(tween._position + (tween.useFrames and GTween.timeScaleAll or dt) * tween.timeScale) end

Likes: fxone, talis

+1 -1 (+2 / -0 )Share on Facebook

Comments

Sign In or Register to comment.