disappearing images that come back every X second after you clicked on them +

I am currently trying to have a button or image popup ever X seconds and reappear,

I am having some trouble in getting the image to reappear/

Here is the code any suggestions? 

 function func(params)

                

         local function handleButtonEvent( event )

            if ( “ended” == event.phase ) then

               local butnresponse=nil

            –   myGroupB:removeSelf()

            –   myGroupB = display.newGroup()

                 myGroupB.isVisible=false

                --passbttn:removeSelf()

                end

            end

            

             object=display.newImage()

            passbttn = widget.newButton(

            {

            width = 240,

            height = 120,

            defaultFile = “pass2.png”,

            overFile = “pass2.png”,

            label = “pass”,

            onEvent = handleButtonEvent

            })

            --passbttn.isVisible=true

            myGroupB:insert(passbttn)

            print(“Popup”)

            passbttn.isVisible=true      

    end

    local timer_popup= timer.performWithDelay(10, func )

     myGroupB.isVisible=true

Hey msiteq,

first of all you should put your code in code-Tags to make it more readable.

In general I would suggest to create the image/button only once and show or hide it as you want.

I’m not quite sure what you want to achive, but I guess, you want the image/button to be removed as it’s cklicked and let it reapear some seconds later.

If that’s what you want, try something like this:

local group, button local buttonTimer local function showButton() button.isVisible = true end local function buttonPress(event) if event.phase == "ended" then button.isVisible = false buttonTimer = timer.performWithDelay(1000, showButton) end end group = display.newGroup() button = widget.newButton( { width = 240, height = 120, defaultFile = "pass2.png", overFile = "pass2.png", label = "pass", onEvent = buttonTouch }) button.isVisible = false group:insert(button)

Note that this solution only works for a single button. If you want more, you would need a different approach.

Greetings

Torben

 local function showButton() button.isVisible = true end local function buttonPress(event) if event.phase == "ended" then button.isVisible = false print("Pass button pressed") buttonTimer = timer.performWithDelay(10000, showButton) end end group = display.newGroup() button = widget.newButton( { width = 240, height = 120, defaultFile = "pass2.png", overFile = "pass2.png", label = "pass", onEvent = buttonPress }) button.isVisible = true group:insert(button)

 Thank you for the code I wasn’t sure why included buttnTouch for the onEvent but I just changed it to buttonpress.

Thank you very much for this code I really appreciate it. 

Do you have any advice on multi-touch 

I thought I had it covered with  (below)

system.activate( "multitouch" )

but when I installed the APK on a phone it did not respond for multitouches only single touches  

function Graph:tap(event) local locationX=event.x local locationY=event.y local brush=display.newCircle(locationX,locationY,3) brush:setFillColor(0.1,0.5,1) --Recorder counter=counter+1 local RPS="X: "..locationX.." Y: "..locationY table.insert(MyTable,counter,RPS) table.insert(LTX,counter,locationX) table.insert(LTY,counter,locationY) local Xmax= 0 local Xmin= 300 local Ymax= 0 local Ymin= 300 --Print Table for i=1,#MyTable do --print ("RPS: "..MyTable[i]) --print ("LTX: "..LTX[i].." MaxX: "..table.maxn(LTX).." LTY: "..LTY[i].." MaxY: "..table.maxn(LTY)) --print ("LTX: "..LTX[i].." LTY: "..LTY[i]) print ("LTY: "..LTY[i]) print ("LTX: "..LTX[i]) -- Sorting if Xmax \< LTX[i] then -- print ("OLD X Max: "..Xmax) Xmax=nil Xmax =LTX[i] --print ("NEW X Max: "..Xmax) end if Xmin \> LTX[i] then --print ("OLD X Min: "..Xmin) Xmin=nil Xmin =LTX[i] --print ("NEW X Min: "..Xmin) end if Ymax \< LTY[i] then --print ("OLD Y Max: "..Xmax) Ymax=nil Ymax =LTY[i] --print ("NEW Y Max: "..Ymax) end if Ymin \> LTY[i] then --print ("OLD Y Min: "..Ymin) Ymin=nil Ymin =LTY[i] --print ("NEW Y Min: "..Ymin) end --report end

One update I managed to get simultaneous touch by changing tap to touch however when I install it on my phone I cannot seem to detect all touches is that possible with current phones?? 

Hey msiteq,

as you already worked out, multitouch onlay works with touch events (as the name says :wink: )

How are you trying to check for these simultaneous touch events?

Lol I figured that was the case, I am using a function that is now recording the touches I just cant find a way to record all touches similar to finger printing 

 function Graph:touch(event) local locationX=event.x local locationY=event.y brush=display.newCircle(locationX,locationY,3) brush:setFillColor(0.1,0.5,1) myGroup:insert(brush) --Recorder counter=counter+1 local RPS="X: "..locationX.." Y: "..locationY table.insert(MyTable,counter,RPS) table.insert(LTX,counter,locationX) table.insert(LTY,counter,locationY) local Xmax= 0 local Xmin= 300 local Ymax= 0 local Ymin= 300 --Print Table for i=1,#MyTable do --print ("RPS: "..MyTable[i])+ --print ("LTX: "..LTX[i].." MaxX: "..table.maxn(LTX).." LTY: "..LTY[i].." MaxY: "..table.maxn(LTY)) --print ("LTX: "..LTX[i].." LTY: "..LTY[i]) print ("LTY: "..LTY[i]) print ("LTX: "..LTX[i]) -- Sorting if Xmax \< LTX[i] then -- print ("OLD X Max: "..Xmax) Xmax=nil Xmax =LTX[i] --print ("NEW X Max: "..Xmax) end if Xmin \> LTX[i] then --print ("OLD X Min: "..Xmin) Xmin=nil Xmin =LTX[i] --print ("NEW X Min: "..Xmin) end if Ymax \< LTY[i] then --print ("OLD Y Max: "..Xmax) Ymax=nil Ymax =LTY[i] --print ("NEW Y Max: "..Ymax) end if Ymin \> LTY[i] then --print ("OLD Y Min: "..Ymin) Ymin=nil Ymin =LTY[i] --print ("NEW Y Min: "..Ymin) end --report end composer.setVariable(conv,"conv") local Width= Xmax-Xmin local Length= Ymax - Ymin local Radius= ((Width/2)\*math.pi) local Radsq = Radius\*Radius local Volume= math.pi\*Radsq\*Length print("Ymax: "..Ymax) print("Ymin: "..Ymin) print("Length: "..Length) print("Width: "..Width) print("Radius= "..Radius) print("Volume= "..Volume) --Calibration=Ymax-Ymin testvalue={} testvalue[1]=Volume testvalue[2]=Width testvalue[3]=Length print ("\n--------------------------------------------------------------------------------") end Graph:addEventListener("touch",object)

Hey msiteq,

first of all you should put your code in code-Tags to make it more readable.

In general I would suggest to create the image/button only once and show or hide it as you want.

I’m not quite sure what you want to achive, but I guess, you want the image/button to be removed as it’s cklicked and let it reapear some seconds later.

If that’s what you want, try something like this:

local group, button local buttonTimer local function showButton() button.isVisible = true end local function buttonPress(event) if event.phase == "ended" then button.isVisible = false buttonTimer = timer.performWithDelay(1000, showButton) end end group = display.newGroup() button = widget.newButton( { width = 240, height = 120, defaultFile = "pass2.png", overFile = "pass2.png", label = "pass", onEvent = buttonTouch }) button.isVisible = false group:insert(button)

Note that this solution only works for a single button. If you want more, you would need a different approach.

Greetings

Torben

 local function showButton() button.isVisible = true end local function buttonPress(event) if event.phase == "ended" then button.isVisible = false print("Pass button pressed") buttonTimer = timer.performWithDelay(10000, showButton) end end group = display.newGroup() button = widget.newButton( { width = 240, height = 120, defaultFile = "pass2.png", overFile = "pass2.png", label = "pass", onEvent = buttonPress }) button.isVisible = true group:insert(button)

 Thank you for the code I wasn’t sure why included buttnTouch for the onEvent but I just changed it to buttonpress.

Thank you very much for this code I really appreciate it. 

Do you have any advice on multi-touch 

I thought I had it covered with  (below)

system.activate( "multitouch" )

but when I installed the APK on a phone it did not respond for multitouches only single touches  

function Graph:tap(event) local locationX=event.x local locationY=event.y local brush=display.newCircle(locationX,locationY,3) brush:setFillColor(0.1,0.5,1) --Recorder counter=counter+1 local RPS="X: "..locationX.." Y: "..locationY table.insert(MyTable,counter,RPS) table.insert(LTX,counter,locationX) table.insert(LTY,counter,locationY) local Xmax= 0 local Xmin= 300 local Ymax= 0 local Ymin= 300 --Print Table for i=1,#MyTable do --print ("RPS: "..MyTable[i]) --print ("LTX: "..LTX[i].." MaxX: "..table.maxn(LTX).." LTY: "..LTY[i].." MaxY: "..table.maxn(LTY)) --print ("LTX: "..LTX[i].." LTY: "..LTY[i]) print ("LTY: "..LTY[i]) print ("LTX: "..LTX[i]) -- Sorting if Xmax \< LTX[i] then -- print ("OLD X Max: "..Xmax) Xmax=nil Xmax =LTX[i] --print ("NEW X Max: "..Xmax) end if Xmin \> LTX[i] then --print ("OLD X Min: "..Xmin) Xmin=nil Xmin =LTX[i] --print ("NEW X Min: "..Xmin) end if Ymax \< LTY[i] then --print ("OLD Y Max: "..Xmax) Ymax=nil Ymax =LTY[i] --print ("NEW Y Max: "..Ymax) end if Ymin \> LTY[i] then --print ("OLD Y Min: "..Ymin) Ymin=nil Ymin =LTY[i] --print ("NEW Y Min: "..Ymin) end --report end

One update I managed to get simultaneous touch by changing tap to touch however when I install it on my phone I cannot seem to detect all touches is that possible with current phones?? 

Hey msiteq,

as you already worked out, multitouch onlay works with touch events (as the name says :wink: )

How are you trying to check for these simultaneous touch events?

Lol I figured that was the case, I am using a function that is now recording the touches I just cant find a way to record all touches similar to finger printing 

 function Graph:touch(event) local locationX=event.x local locationY=event.y brush=display.newCircle(locationX,locationY,3) brush:setFillColor(0.1,0.5,1) myGroup:insert(brush) --Recorder counter=counter+1 local RPS="X: "..locationX.." Y: "..locationY table.insert(MyTable,counter,RPS) table.insert(LTX,counter,locationX) table.insert(LTY,counter,locationY) local Xmax= 0 local Xmin= 300 local Ymax= 0 local Ymin= 300 --Print Table for i=1,#MyTable do --print ("RPS: "..MyTable[i])+ --print ("LTX: "..LTX[i].." MaxX: "..table.maxn(LTX).." LTY: "..LTY[i].." MaxY: "..table.maxn(LTY)) --print ("LTX: "..LTX[i].." LTY: "..LTY[i]) print ("LTY: "..LTY[i]) print ("LTX: "..LTX[i]) -- Sorting if Xmax \< LTX[i] then -- print ("OLD X Max: "..Xmax) Xmax=nil Xmax =LTX[i] --print ("NEW X Max: "..Xmax) end if Xmin \> LTX[i] then --print ("OLD X Min: "..Xmin) Xmin=nil Xmin =LTX[i] --print ("NEW X Min: "..Xmin) end if Ymax \< LTY[i] then --print ("OLD Y Max: "..Xmax) Ymax=nil Ymax =LTY[i] --print ("NEW Y Max: "..Ymax) end if Ymin \> LTY[i] then --print ("OLD Y Min: "..Ymin) Ymin=nil Ymin =LTY[i] --print ("NEW Y Min: "..Ymin) end --report end composer.setVariable(conv,"conv") local Width= Xmax-Xmin local Length= Ymax - Ymin local Radius= ((Width/2)\*math.pi) local Radsq = Radius\*Radius local Volume= math.pi\*Radsq\*Length print("Ymax: "..Ymax) print("Ymin: "..Ymin) print("Length: "..Length) print("Width: "..Width) print("Radius= "..Radius) print("Volume= "..Volume) --Calibration=Ymax-Ymin testvalue={} testvalue[1]=Volume testvalue[2]=Width testvalue[3]=Length print ("\n--------------------------------------------------------------------------------") end Graph:addEventListener("touch",object)