Hi guys!
Today I need help to make a mini “lives bar” using circles.
I create the circles using a table and I want to update the number of “lives” and the “circle” display object that represent that number at the same time, I also want to put the current number of lives in a variable and pass the parameters to my “reload” scene with composer set and get variable. This is what I have.
local lives = {} local numOfLives = 3 local loseLive = 3 --create the lives for i = 1, numOfLives do lives[i] = display.newCircle( 0, 0, 5 ) lives[i]:setFillColor( 1, 1 , 1 ) sceneGroup:insert( lives[i] ) end lives[1].x = centerX; lives[1].y = \_T+50 lives[2].x = lives[1].x+20; lives[2].y = \_T+50 lives[3].x = lives[2].x+20; lives[3].y = \_T+50 --function to update lives local function updateLives( event ) local lastLive = lives[i] - 1 -- HERE I GET AN ERROR display.remove(lastLive) loseLive = loseLive - 1 composer.setVariable( "loseLive", loseLive - 1 ) if loseLive == 0 then local options = { effect = "crossFade", time = 100 } composer.gotoScene( "levels.menu", options ) end end
the problem here is I’m not an expert in tables, its easy to do it like “Star Explorer” using text but I want to make it with display objects.
any help to achieve this task?
DoDi