Hi!
I’m making a game where you get score as long as you are alive. I’ve made a code that works, but I don’t know if this is the way to do it.
if event.time - timeLastScore \>= 1 then
local scoreBall = display.newImage("score.png")
scoreBall.x = 1
scoreBall.y = 1
physics.addBody(scoreBall, "kinematic", {bounce = 0})
score = score + 1
scoreText.text = score
transition.to(scoreBall, {time = 1, x = -1, onComplete = function(self) self.parent:remove(self); self = nil; end})
timeLastScore = event.time
end
Is there a smarter way to do it?
Best regards,
joelwe [import]uid: 54640 topic_id: 9750 reply_id: 309750[/import]
[import]uid: 54640 topic_id: 9750 reply_id: 36209[/import]