Advertisement
alestane

Life counter

Oct 12th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1.     local lives = 5
  2.     local lifeIcons={}
  3.         local maxLives = 5
  4.         local i
  5.         local function health(currentLives)
  6.            for i = 1, currentLives do
  7.             if lifeIcons[i] then
  8.                 lifeIcons[i].isVisible = true
  9.             else
  10.                 lifeIcons[i] = display.newImage("heart.png")
  11.                 lifeIcons[i].x = 10 + (lifeIcons[i].contentWidth * (i - 1))
  12.                 lifeIcons[i].y = 30 -- start at 10,10
  13.             end
  14.             end
  15.         for i = currentLives + 1, #lifeIcons do
  16.             lifeIcons[i].isVisible = false
  17.         end
  18.         end
  19.         health(maxLives)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement