Skip to content

Instantly share code, notes, and snippets.

@figengungor
Last active December 18, 2015 07:19
Show Gist options
  • Select an option

  • Save figengungor/5745882 to your computer and use it in GitHub Desktop.

Select an option

Save figengungor/5745882 to your computer and use it in GitHub Desktop.
Countdown App 2, with timer.performWithDelay() and transition.to()
--CountDown App 2
W=display.contentWidth/2
H=display.contentHeight/2
local time = 3 -- count down from 3
local gogogo = display.newText("Go go go!", 0, 0, "James Fajardo", 100)
gogogo.alpha=0 --is not visible
gogogo.x=W
gogogo.y=H
local timeSound=audio.loadSound("button.wav")
local function decreaseTime()
local count = display.newText(time.."", 0, 0, nil, 100)
count.x=W
count.y=H
time = time-1
transition.to(count, {time=1000, alpha=0} ) --fading the numbers away in 1000 miliseconds
local channel = audio.play(timeSound)
if(time==0) then --delay is needed to wait for above transition.
transition.to(gogogo, {time=1000, delay=1000, alpha=1} ) --making visible by setting alpha 1 with 1000 miliseconds delay and
end --in 1000 miliseconds easing
end
timer.performWithDelay(1000,decreaseTime,3) --calls decreaseTime 3 times with 1 second delay (3.parameter should be time variable's first value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment