double tapping doo dah

i have this in  a main.lua so that the player can double tap to check info on the game , regardless of the scene. It shows the first the first time but afret that it refuses to hide itself or even get to the elseif statement

local data = require "data"   Runtime:addEventListener("tap", function (event)     if data.isntLevel then         return false     elseif event.numTaps == 2 then                print( data.isShowingInfo )         if data.isShowingInfo%2 == 1 then             composer.showOverlay("levelinfo", {isModal = true})         else             print("hidden")             composer.hideOverlay("levelinfo")         end         data.isShowingInfo = data.isShowingInfo +1         return true     end end)    

Hi @86lemonade68,

At an initial glance, I suspect there’s something going wrong in your conditional logic, or that a variable isn’t being reset somewhere. I also see that you increment “data.isShowingInfo”… is that some kind of flag? If so, why not use a boolean true/false instead of incrementing it? And if you’re incrementing it, where do you decrement it? Maybe I’m not fully clear on what you’re attempting with this setup.

Best regards,

Brent

with the %2 i put after “data.isShowingInfo” it means that it will go something like this if i print it 1,0,1,0,1,0,1,0 etc …

Fixed it thanks for the help Brent

Regards,

Lemon

Hi @86lemonade68,

At an initial glance, I suspect there’s something going wrong in your conditional logic, or that a variable isn’t being reset somewhere. I also see that you increment “data.isShowingInfo”… is that some kind of flag? If so, why not use a boolean true/false instead of incrementing it? And if you’re incrementing it, where do you decrement it? Maybe I’m not fully clear on what you’re attempting with this setup.

Best regards,

Brent

with the %2 i put after “data.isShowingInfo” it means that it will go something like this if i print it 1,0,1,0,1,0,1,0 etc …

Fixed it thanks for the help Brent

Regards,

Lemon