Counter issues

Hi everyone,

I’m new to Corona and having problems with a counter.

Basically, instead of updating the text as the counter decreases, the text is being displayed on the screen, overlapping the old text.

Can anyone suggest what could be the possible reason for this? Or if there is a dead easy way to create a counter? :stuck_out_tongue:
Thanks! [import]uid: 40538 topic_id: 7467 reply_id: 307467[/import]

I use this for a countdown timer for my game, just change the value of obj.text:

module(…, package.seeall)
–Setup Groups
local localGroup = display.newGroup()

–Init Variables
local timeLimit = 10

–Display Objects
local timeLimitText = display.newText(tostring(timeLimit), 0, 0, sysFont, 25)

local function showTime(event)
timeLimit = timeLimit - 1
timeLimitText.text = tostring(timeLimit)
if timeLimit == 0 then
checkItems()
end
end

local function initVars()

–Insert Objects into Group
localGroup:insert(timeLimitText)

–Start Level
local function startLevel(event)
–Listeners
local checkTime = timer.performWithDelay(1000, showTime, timeLimit)
end

–Clean Function
function clean(event)
print(“Cleaned”)
end
function new()
–Init Varaibles
initVars()

–Return localGroup to Director Class
return localGroup
end [import]uid: 11809 topic_id: 7467 reply_id: 26442[/import]

Thanks for your reply, but it’s a counter which reduces as events happen, similar to a “lives” counter.
Cheers [import]uid: 40538 topic_id: 7467 reply_id: 26451[/import]

The same thing would apply like this
local livesText = display.newText(“3”, 0,0,native.systemFont,12)
local numberOfLives = 3

function do()
numberOfLives = numberOfLives - 1
livesText.text = tostring(numberOfLives)
end [import]uid: 11809 topic_id: 7467 reply_id: 26456[/import]

Just what I was looking for - thanks! [import]uid: 40538 topic_id: 7467 reply_id: 26975[/import]