question on isVisible = true

I’m trying to get an object “obj1” to show(isVisible = true) at the push of a button. (it’s a yellow rect)

using – timer.performWithDelay(1000, newListener ), a new rect “obj2” will show and “obj1” will hide.

then “obj3” at 2 seconds show and obj2 hide, just like that in a sequence.

– That’s easy I can do that so far.


I have a “stop” button, or “done” or “reset” button


so when people push that button “everything” must end or stop.


I have one function for each “obj”

local function yellow1 ()     local function obj11Listener( event )         obj1.isVisible = true     end     timer.performWithDelay( 200, obj1Listener ) end   local function yellow2 ()         local function obj2Listener( event )         obj1.isVisible = false         obj2.isVisible = true     end     timer.performWithDelay(3130, obj2Listener ) end

like that.

in another function I call all of them at the same time

local function pennyTap ()             local function play ()                 audio.play(pennySong)             end             transition.to(pennyImageLarge, {time=200, x=display.contentWidth / 2, y=display.contentHeight / 2, xScale=1, yScale=1, alpha=1, onComplete=play})             transition.to(done, {time=200, y=700})             yellow1()             yellow2()             yellow3()             yellow4() -- and so on         end

in the done button I have this

local function doneStop ()             audio.stop()             transition.to(done, {time=200, y=900})             transition.to(pennyImageLarge, {time=200, x=pennyImage.x, y=pennyImage.y, xScale=.1, yScale=.1, alpha=0})             obj1.isVisible = false             obj2.isVisible = false             obj3.isVisible = false             obj4.isVisible = false         end

even when all the objects are = false

because of the previews calls I keep seeing the rects show and hide

how can I solve this problem?

any suggestions on a new and better approach for this problem?

thanks for your help.

You should assign the timer calls to variables, then cancel them all in your done function. Keep in mind scope, so you’ll need forward references to the timer variables.

it make sense…

how do I do that?

I tried this – didn’t work

– local timer1 = timer.performWithDelay( 200, measure1Listener )

I don’t know how

I found this on line

it is what you just said and it works great!

exactly what I need it

local throwBrickTimer -- Reference for the timer function scene:enterScene(event) planeta.enterFrame = rotarPlaneta Runtime:addEventListener("enterFrame", planeta) Runtime:addEventListener("touch", touchScreen) --\> Give the timer a variable throwBrickTimer = timer.performWithDelay( 1000, throwBrickEnemigo,0 ) end function scene:exitScene(event) --\> Cancel the timer timer.cancel(throwBrickTimer) Runtime:removeEventListener("enterFrame", planeta) Runtime:removeEventListener("enterFrame", touchScreen) Runtime:removeEventListener("enterFrame", planeta) end

it feels so good to learn one more thing.

I probably know about 24 functions do do different things

I wonder how many there are?

You should assign the timer calls to variables, then cancel them all in your done function. Keep in mind scope, so you’ll need forward references to the timer variables.

it make sense…

how do I do that?

I tried this – didn’t work

– local timer1 = timer.performWithDelay( 200, measure1Listener )

I don’t know how

I found this on line

it is what you just said and it works great!

exactly what I need it

local throwBrickTimer -- Reference for the timer function scene:enterScene(event) planeta.enterFrame = rotarPlaneta Runtime:addEventListener("enterFrame", planeta) Runtime:addEventListener("touch", touchScreen) --\> Give the timer a variable throwBrickTimer = timer.performWithDelay( 1000, throwBrickEnemigo,0 ) end function scene:exitScene(event) --\> Cancel the timer timer.cancel(throwBrickTimer) Runtime:removeEventListener("enterFrame", planeta) Runtime:removeEventListener("enterFrame", touchScreen) Runtime:removeEventListener("enterFrame", planeta) end

it feels so good to learn one more thing.

I probably know about 24 functions do do different things

I wonder how many there are?