I have a power bar animation which is very simple but appears to fail. What I’m expecting is for a red rectangle, which is twice the width of the screen, to be moved left until it’s right side touches the left of the screen (power bar draining away effect.)
What I see is that the bar drains down but does not immediately disappear. If you run this code do you see the same thing?
I’ve tried using the transition.to onComplete and a separate timer.performWithDelay, both with the same effect.
display.setStatusBar( display.HiddenStatusBar ) local function timerbar( callback ) local group = display.newGroup() group.class = "timerbar" local bar = display.newRect( group, 0, 0, display.contentWidth\*2, 100 ) bar.fill = {1,0,0} local function fin() print(1) bar:removeSelf() bar = nil print(2) callback() print(3) end transition.to( bar, { time=4000, width=-display.contentWidth } ) timer.performWithDelay( 4000, fin, 1 ) return group end local function go() print("GO") end timerbar( go )