Good, now it works fine…thanks. with a simple 3 dots.
Now when I try that in MY real code, actually using the waiting time…
PROBLEMS!!! This is giving me headaches…
Sorry the code is long but please help me out.
The Last function is the one we are working on
just scrol down to the end…
(I put all of them just in case)
I have a normal function to add score or life
function addToLife() lifeTxt.isVisible = true life = archivo.datos.life life = life + 1 archivo.datos.life = life archivo:guarda() lifeTxt.text = life end
Now the function to waiting period…
function collectLife() local lifeDuration = os.time() local function waitingLife() local nowGetLife = os.time() if ( nowGetLife \> lifeDuration + 5 ) then cofre[visibleObject].isVisible = true end end lifeTimer = timer.performWithDelay(20000, waitingLife) end
then a little function to tell me that the little diamon (diamantito) got to his place
function yaLlego() diamantito.isVisible = false end
Now for the diamond to move to the center of the screen
function juntaVidita() transition.to(diamantito, { time=10, x = display.contentCenterX + 2000, y = display.contentCenterY - 1020, xScale = .3, yScale = .3, rotation = 0, alpha = 0, onComplete = yaLlego }) end
this is to make the objects dissapear – cofre is the object
function vidita() diamantito.alpha = 1 diamantito.isVisible = true transition.to(diamantito, { time=1500, x = display.contentCenterX, y = display.contentCenterY, xScale = 2, yScale = 2, rotation = 130, transition = easing.inSine, --alpha = 0, onComplete = juntaVidita }) if (viditaRound == 1) then transition.to(cofre[1], { time=200, xScale = 0.01, yScale = 0.01, alpha = 0 }) viditaRound = 2 elseif (viditaRound == 2) then transition.to(cofre[2], { time=200, xScale = 0.01, yScale = 0.01, alpha = 0 }) viditaRound = 3 elseif (viditaRound == 3) then transition.to(cofre[3], { time=200, xScale = 0.01, yScale = 0.01, alpha = 0 }) viditaRound = 4 else return true end addToLife() collectLife() end
And finally here is the function that will make the magic…
function cofreListener( event ) if event.phase == "began" then if ( event.target.id ) == 1 then -- obj 1 is gone! cofre[1].isVisible = false --Bump the visible object counter visibleObject=visibleObject+1 --Make the current object invisible cofre[visibleObject].isVisible=false --Don't overflow if (visibleObject==4) then visibleObject=1 end --Make the next object visible --cofre[visibleObject].isVisible=true diamantito.x = cofre[1].x diamantito.y = cofre[1].y plus1.x = cofre[1].x plus1.y = cofre[1].y if (viditaRound == 1) then vidita() end elseif ( event.target.id ) == 2 then print("2") -- obj 2 is gone! cofre[2].isVisible = false --Bump the visible object counter visibleObject=visibleObject+1 --Make the current object invisible cofre[visibleObject].isVisible=false --Don't overflow if (visibleObject==4) then visibleObject=1 end --Make the next object visible --cofre[visibleObject].isVisible=true diamantito.x = cofre[2].x diamantito.y = cofre[2].y plus1.x = cofre[2].x plus1.y = cofre[2].y if (viditaRound == 2) then vidita() end elseif ( event.target.id ) == 3 then print("3") -- obj 3 is gone! cofre[3].isVisible = false --Bump the visible object counter visibleObject=visibleObject+1 --Make the current object invisible --objs[visibleObject].isVisible=false --Don't overflow if (visibleObject==4) then visibleObject=1 end --Make the next object visible --cofre[visibleObject].isVisible=true diamantito.x = cofre[3].x diamantito.y = cofre[3].y plus1.x = cofre[3].x plus1.y = cofre[3].y if (viditaRound == 3) then vidita() end end return true end end
Sorry I have no other way to do this… I guess it should be an easier way
or faster or better, but this is all I know…
Thanks a lot for your help
Victor