I have a simple flashing box to alert someone when a timer is almost expired and it worked very well, but then I decided I needed to add another item to flash along with it.
local topRedAlertRectAngled = display.newRect( group, 0, 0, 0, 0 )
topRedAlertRectAngled.x = settingsRect.x-99
topRedAlertRectAngled.y = settingsRect.y+99
topRedAlertRectAngled.width = settingsRect.width \* .8
topRedAlertRectAngled.height = settingsRect.height \* 1.015
topRedAlertRectAngled.rotation = 45
topRedAlertRectAngled.strokeWidth = 3
topRedAlertRectAngled:setFillColor(0,0,0,0)
topRedAlertRectAngled:setStrokeColor(255, 255, 255,255)
topRedAlertRectAngled.alpha = 0
local topRedAlertRect = display.newRect( group, 0, 0, (otherRect.width \* .9), (otherRect.height \* .9) )
topRedAlertRect.x = topRedRect.x
topRedAlertRect.y = topRedRect.y
topRedAlertRect.strokeWidth = 3
topRedAlertRect:setFillColor(0,0,0, 0)
topRedAlertRect:setStrokeColor(255, 255, 255)
topRedAlertRect.alpha = 0
local function flashTopRedAlert(theRect, theAngledRect)
local function printMessage()
print("red transition done")
end
local function revertFlash()
transition.to(theAngledRect, { time = 750, alpha = 0, transition = easingx.easeIn, onComplete = printMessage})
transition.to(theRect, { time = 750, alpha = 0, transition = easingx.easeIn, onComplete = flashTopRedAlert })
end
if(keepTopRedRunning == 1)
then
transition.to(theAngledRect, { time = 750, alpha = 1, transition = easingx.easeIn, onComplete = printMessage})
transition.to(theRect, { time = 750, alpha = 1, transition = easingx.easeIn, onComplete = revertFlash })
end
end
The transition on “theRect” works perfectly and repeatedly until “keepTopRedRunning” is turned off. The strange part is that the transitions on “theAngledRect” fire the first time for both of the transitions, but then don’t fire again.
I tried adding the two rects to a display group and transitioning the alpha of the display group, but that didn’t work at all (is transitioning the alpha of a display group not possible?). I confirmed that the transitions were working by transitioning the groups x coordinate. It moved around, but the alpha didn’t change.
I’d be happy to do it either way (two transitions or one transition on a display group). If anyone has any advice or a fix for this I’d be greatly appreciative. Thanks! [import]uid: 39480 topic_id: 21589 reply_id: 321589[/import]
[import]uid: 52491 topic_id: 21589 reply_id: 85759[/import]