Fade object

How would I make something fade out after a time, but if someone taps it comes back and starts the timer again? [import]uid: 147322 topic_id: 27455 reply_id: 327455[/import]

Run this;
[lua]local myObj = display.newCircle( 160, 200, 40 )

local function touchObj()
if fadeTrans then
transition.cancel(fadeTrans)
fadeTrans = nil
myObj.alpha = 1
fadeTrans = transition.to(myObj, {time=2000, alpha = 0})
end
end
myObj:addEventListener(“tap”, touchObj)

fadeTrans = transition.to(myObj, {time=2000, alpha = 0})[/lua]

If you want them to be able to also bring it back when alpha is 0 then add line; myObj.isHitTestable = true

Peach :slight_smile: [import]uid: 52491 topic_id: 27455 reply_id: 111639[/import]