Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------
- --STAMINA.LUA CLASS
- ---------------------
- local _M = {}
- local screen =
- {
- left = display.screenOriginX,
- top = display.screenOriginY,
- right = display.contentWidth - display.screenOriginX,
- bottom = display.contentHeight - display.screenOriginY
- };
- staminaGroup = display.newGroup()
- staminaGroup.x = screen.left; staminaGroup.y = screen.top +10
- _M.lives = 2
- _M.staminaInit = {}
- for i = 1, 4 do
- _M.staminaInit[i] = display.newImage("staminaEmpty.png", 25 + (i * 25), 25)
- staminaGroup:insert(_M.staminaInit[i])
- end
- _M.staminaLives = {}
- for i = 1, _M.lives do
- _M.staminaLives[i] = display.newImage("staminaFull.png", 25 + (i * 25), 25)
- staminaGroup:insert(_M.staminaLives[i])
- end
- function _M:life(addOrSub) --use add or sub as args
- if _M.lives > 0 then
- if addOrSub == "add" then
- if _M.lives < 4 then
- _M.lives = _M.lives + 1
- return _M.lives
- end
- elseif addOrSub == "sub" then
- _M.lives = _M.lives - 1
- return addOrSub
- end
- else
- print("ure dead man!")
- end
- end
- return _M
- -----------------------
- -- IN MAIN.LUA FILE
- -----------------------
- local stamina = require ("stamina")
- stamina:life("sub")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement