Corona sdk Scoring

I’m trying to make a simple corona sdk game but I can’t get it working. The score text just doesn’t change.

 

 

The functions:

 

function points(num)
addPoints()
score = score + num
scoreTxt.text = "score: " … score
scoreTxt:setReferencePoint(display.TopLeftReferencePoint)
end

function addPoints()
num = math.random(100, 350)
end

Some other information:

score = 50;
num = 50;
scoreTxt = display.newText (“Score:”, 0, 0, “Helvetica”, 20)
scoreTxt:setReferencePoint(display.TopLeftReferencePoint)
scoreTxt.x = display.screenOriginX + 10
scoreTxt.y = display.screenOriginX + 5

Thanks in advance :slight_smile:

Where in your code are you calling the points() function (which is what causes the scoreTxt object to actually update)?

  • Andrew

As above, your function addPoints() doesn’t call points()

Sorry for late reaction but everything works fine now.

Just forgot to call the function :stuck_out_tongue:

Where in your code are you calling the points() function (which is what causes the scoreTxt object to actually update)?

  • Andrew

As above, your function addPoints() doesn’t call points()

Sorry for late reaction but everything works fine now.

Just forgot to call the function :stuck_out_tongue: