Simple Transition.To alpha tween is failing

Hey everyone I just started to play with Corona, and I’ve got a problem. I’m trying to fade in an overlay rectangle to effectively blur out the screen contents like this:

[lua]_w = display.contentWidth
_h = display.contentHeight

_overlay = display.newRect(0, 0, _w, _h)
_overlay:setFillColor(255, 64, 64, 0)
transition.to(_overlay, { time = 1000, alpha = 0.3})[/lua]

But nothing happens :frowning: Even if I set alpha to 1.0, I don’t get the rectangle drawn.

If I change the _overlay:setFillColor(255, 64, 64, 0) alpha index to 255, it shows up fine, so I know that the rectangle is being drawn with the correct position and size.

Does anyone know whats going on? [import]uid: 50524 topic_id: 8606 reply_id: 308606[/import]

try setting the fill color to (255,64,64,255), and the _overlay.alpha to 0, then doing the transition.

you’ve not set your object to alpha 0, you’ve set the fill to alpha 0, so even at the object’s full alpha it’s fill is still zero … 1 * 0 = 0 ! [import]uid: 6645 topic_id: 8606 reply_id: 30909[/import]

From my understanding of what’s happening here, when you put (255, 64, 64, 0), you actually set the fill color’s alpha to 0, not the alpha of the object _overlay itself. Try setting the alpha of the object to 0, and remove that 0 at the end of your setFillColor

[lua]_w = display.contentWidth
_h = display.contentHeight

_overlay = display.newRect(0, 0, _w, _h)
_overlay:setFillColor(255, 64, 64)
_overlay.alpha = 0
transition.to(_overlay, {time = 1000, alpha = 0.3})[/lua] [import]uid: 45459 topic_id: 8606 reply_id: 30911[/import]

Quite right gentlemen! Thanks for the tip, its working beautifully now. [import]uid: 50524 topic_id: 8606 reply_id: 30953[/import]