Hi, sorry for my google english. I am working with the Sticker-Knight-Platformer life module, the life limit is set to 5. Is there a way to remove the limit and add more lives? I have tried in many ways but I can’t, I can add lives but not the image. My intention to start the game with 5 lives but no limit.
I hope I have explained myself.
regards
-- Define module
local M = {}
function M.new( options )
-- Opciones predeterminadas, por ejemplo:
options = options or {}
local image = options.image
local max = options.max or 5--Cantidad máxima de vidas
local spacing = options.spacing or 30 --Separación entre vidas
local w, h = options.width or 64, options.height or 64 --Tamaño png de las vidas
-- Crear grupo de visualización para mostrar imágenes
grupovidas = display.newGroup()
local hearts = {}
for i = 1, max do
hearts[i] = display.newImageRect( "scene/game/img/shield.png", w, h )
hearts[i].x = (i-1) * ( (w/2) + spacing )
hearts[i].y = 0
grupovidas:insert( hearts[i] )
end
grupovidas.count = max
function grupovidas:damage( amount )
grupovidas.count = math.min( math.max( 0, grupovidas.count - ( amount or 1 ) ) )
for i = 1, max do
if i <= grupovidas.count then
hearts[i].alpha = 1
else
hearts[i].alpha = 0.2
end
end
return grupovidas.count
end
function grupovidas:heal( amount )
self:damage( -( amount or 1 ) )
end
function grupovidas:finalize()
-- eliminación de los objetos del grupo, instancia de limpieza
end
grupovidas:addEventListener( "finalize" )
-- Return instance
return grupovidas
end
return M