how to fade out , fade in object with 10 seconds…
i want my apple object to fade in , fade out,fade in , fade out in 10 seconds…
i don’t know how
i think its looping…
how to fade out , fade in object with 10 seconds…
i want my apple object to fade in , fade out,fade in , fade out in 10 seconds…
i don’t know how
i think its looping…
Hi,
Maybe this can help you get started:
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local rect = display.newRect(100,100, 100, 100) local counter = 0 function zoom() counter = counter + 1 if counter == 300 then zoomIn(rect) elseif counter == 600 then counter = counter - 600 zoomOut(rect) end end function zoomIn(obj) print("zoomIn") transition.to(obj, {xScale = 2, yScale = 2}) end function zoomOut(obj) print("zoomOut") transition.to(obj, {xScale = 0.5, yScale = 0.5}) end Runtime:addEventListener("enterFrame", zoom)
This is assumed that the FPS is set to 30 in the config file (which it is by default).
Also, I’m not sure if Corona sometime skips an FPS, if so then having counter == 300 is not a good idea and you should try to use another comparision (maybe using the modulo operator?).
Best regards,
Tomas
You can also add time to the transition.to:
transition.to(obj, {time = 10000, xScale = 0.5, yScale = 0.5})
You can also change the FPS to 60 so it looks smoother but that will consume more battery.
Best regards,
Tomas
ok sir … tnx … i used ur zoom in…
Also, you could mess with ‘blink’ (it’s part of the new transition library). I’m using it in build 1260. You simple just set the amount of time you want and it does it automatically in one line.
Hi,
Maybe this can help you get started:
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local rect = display.newRect(100,100, 100, 100) local counter = 0 function zoom() counter = counter + 1 if counter == 300 then zoomIn(rect) elseif counter == 600 then counter = counter - 600 zoomOut(rect) end end function zoomIn(obj) print("zoomIn") transition.to(obj, {xScale = 2, yScale = 2}) end function zoomOut(obj) print("zoomOut") transition.to(obj, {xScale = 0.5, yScale = 0.5}) end Runtime:addEventListener("enterFrame", zoom)
This is assumed that the FPS is set to 30 in the config file (which it is by default).
Also, I’m not sure if Corona sometime skips an FPS, if so then having counter == 300 is not a good idea and you should try to use another comparision (maybe using the modulo operator?).
Best regards,
Tomas
You can also add time to the transition.to:
transition.to(obj, {time = 10000, xScale = 0.5, yScale = 0.5})
You can also change the FPS to 60 so it looks smoother but that will consume more battery.
Best regards,
Tomas
ok sir … tnx … i used ur zoom in…
Also, you could mess with ‘blink’ (it’s part of the new transition library). I’m using it in build 1260. You simple just set the amount of time you want and it does it automatically in one line.