I have been coding with corona and I took a break for a while but I forgot most of my lua coding. Can someone please help me setup a stop watch, like the text and 2 buttons, start and stop? [import]uid: 39840 topic_id: 15559 reply_id: 315559[/import]
Are you asking someone to write all the code for you, or are you looking for help/suggestions for specific parts? [import]uid: 52491 topic_id: 15559 reply_id: 57460[/import]
no I just need someone to help me setup this [import]uid: 39840 topic_id: 15559 reply_id: 57488[/import]
Test in portrait, just a rough example to get you going - not tested but should work fine.
[lua]local time = 0
local timeText = display.newText(time, 140, 100, “Helvetica”, 26)
local startBtn = display.newRect( 50, 200, 100, 40 )
local stopBtn = display.newRect( 170, 200, 100, 40 )
local function updateTime ()
time = time + 1
timeText.text = time
end
local function pressStart()
myTimer = timer.performWithDelay(1000, updateTime, 0)
end
startBtn:addEventListener(“tap”, pressStart)
local function pressStop()
timer.cancel(myTimer)
end
stopBtn:addEventListener(“tap”, pressStop)[/lua]
Peach [import]uid: 52491 topic_id: 15559 reply_id: 57580[/import]