How to put score for my game, like if i want to add +1 to score if object1 and object2 touch each other ( collide ) and also to put score=0 if object1 hits ground? and how to record high score? what code should i use… [import]uid: 189039 topic_id: 32270 reply_id: 332270[/import]
You can use a simple text object and initialy set text to 0,
local score = 0
local myText = display.newText(score, 0, 0, native.systemFont, 16)
myText:setTextColor(255, 255, 255)
Then on your hit function:
score = score + 1
myText.text = score
Pozdrav! [import]uid: 177091 topic_id: 32270 reply_id: 128396[/import]
ok this way it only displays number and i would like it to say
" score: 0" [import]uid: 189039 topic_id: 32270 reply_id: 128486[/import]
Modified code from above. (Thanks for posting that, good answer!)
[lua]local score = 0
local myText = display.newText(score, 0, 0, native.systemFont, 16)
myText:setTextColor(255, 255, 255)
score = score + 1
myText.text = "score: "…score[/lua]
Peach 
[import]uid: 52491 topic_id: 32270 reply_id: 128502[/import]
You can use a simple text object and initialy set text to 0,
local score = 0
local myText = display.newText(score, 0, 0, native.systemFont, 16)
myText:setTextColor(255, 255, 255)
Then on your hit function:
score = score + 1
myText.text = score
Pozdrav! [import]uid: 177091 topic_id: 32270 reply_id: 128396[/import]
ok this way it only displays number and i would like it to say
" score: 0" [import]uid: 189039 topic_id: 32270 reply_id: 128486[/import]
Modified code from above. (Thanks for posting that, good answer!)
[lua]local score = 0
local myText = display.newText(score, 0, 0, native.systemFont, 16)
myText:setTextColor(255, 255, 255)
score = score + 1
myText.text = "score: "…score[/lua]
Peach 
[import]uid: 52491 topic_id: 32270 reply_id: 128502[/import]
Thanks this helped a lot. Also how to make it display highscore on screen and update it while playing? [import]uid: 189039 topic_id: 32270 reply_id: 128629[/import]
Have variable for highscore.
If score > highscore then
highscore = score
–update highscore text here
end
Easy. [import]uid: 52491 topic_id: 32270 reply_id: 128691[/import]
Thanks this helped a lot. Also how to make it display highscore on screen and update it while playing? [import]uid: 189039 topic_id: 32270 reply_id: 128629[/import]
Have variable for highscore.
If score > highscore then
highscore = score
–update highscore text here
end
Easy. [import]uid: 52491 topic_id: 32270 reply_id: 128691[/import]