Erroneous Button Behaviour

i am using the simulator to test  a game.

Within my “Play” scene I have three buttons.

One of the buttons has the purpose of starting play  or pausing play.

The code is as follows:

function onPlayPlayRelease( event )

    local btn = event.target

    if PlayPause == false then

        PlayPause = true

        PlayPlay:setLabel( “Pausbutton e” )

        Runtime:addEventListener(“tap”, TapListener )

    else

        PlayPause = false

        Runtime:removeEventListener(“tap”, TapListener )

        PlayPlay:setLabel( “Play” ) 

    end

end

I am getting erroneous button actions. That is, while moving the cursor around other parts of the screen it appears the Button Release event is triggered and the Play button keeps switching from “Play” to “Pause”

Any suggestions as to how I can overcome this?

Henry “Pops” Hugo

Can you show the code that calls onPlayPlayRelease()?

Hi Rob,

The code is as follows:

Button Setup function:

function PlayPlayButton()

    PlayPlay = widget.newButton{

    label = “Play”,

    width = 50 * ScalingFactorx, 

    height = 20 * ScalingFactory,

    left = ScrOriginy + 70 *ScalingFactorx, 

    top = ScrOriginy + 10 * ScalingFactory,

    defaultColor ={ 0,255,255,255 }, 

    overColor ={ 0,196,64,255 },

    fontSize = 10 * ScalingFactory,

    labelColor = { default={ 255,0,0,255 }, over={ 0,0,0 } },

    onRelease = onPlayPlayRelease

    }

end    

Scene Entry function:

function scene:enterScene( event )

    local screenGroup = self.view

    storyboard.removeScene(“MenuScene”)

    BackGround(255,255,255)

    PlayMenuButton()

    PlayPlayButton()

    PlaySaveButton()

    AllFilledTriangles()

    AllTriangleLines()

    AllDots()

    TimerStart = timer.performWithDelay( 1000, Tlistener,0 )

    

end

Button Release function:

function onPlayPlayRelease( event )

    local btn = event.target

    if PlayPause == false then

        PlayPause = true

        PlayPlay:setLabel( “Pause” )

        Runtime:addEventListener(“tap”, TapListener )

    else

        PlayPause = false

        Runtime:removeEventListener(“tap”, TapListener )

        PlayPlay:setLabel( “Play” ) 

    end

end

Any Suggestions

Regards Henry “Pops” Hugo

What version of Corona are you using?

Hi Rob, I was using 2012.971. I will download the latest and try that. will let you know the result. It’s just that I tend to start with a particular build and stay with it rather than downloading  the latest all the time.

if you add return true right above the function closing end, do you still get the same behaviour?

 

Can you show the code that calls onPlayPlayRelease()?

Hi Rob,

The code is as follows:

Button Setup function:

function PlayPlayButton()

    PlayPlay = widget.newButton{

    label = “Play”,

    width = 50 * ScalingFactorx, 

    height = 20 * ScalingFactory,

    left = ScrOriginy + 70 *ScalingFactorx, 

    top = ScrOriginy + 10 * ScalingFactory,

    defaultColor ={ 0,255,255,255 }, 

    overColor ={ 0,196,64,255 },

    fontSize = 10 * ScalingFactory,

    labelColor = { default={ 255,0,0,255 }, over={ 0,0,0 } },

    onRelease = onPlayPlayRelease

    }

end    

Scene Entry function:

function scene:enterScene( event )

    local screenGroup = self.view

    storyboard.removeScene(“MenuScene”)

    BackGround(255,255,255)

    PlayMenuButton()

    PlayPlayButton()

    PlaySaveButton()

    AllFilledTriangles()

    AllTriangleLines()

    AllDots()

    TimerStart = timer.performWithDelay( 1000, Tlistener,0 )

    

end

Button Release function:

function onPlayPlayRelease( event )

    local btn = event.target

    if PlayPause == false then

        PlayPause = true

        PlayPlay:setLabel( “Pause” )

        Runtime:addEventListener(“tap”, TapListener )

    else

        PlayPause = false

        Runtime:removeEventListener(“tap”, TapListener )

        PlayPlay:setLabel( “Play” ) 

    end

end

Any Suggestions

Regards Henry “Pops” Hugo

What version of Corona are you using?

Hi Rob, I was using 2012.971. I will download the latest and try that. will let you know the result. It’s just that I tend to start with a particular build and stay with it rather than downloading  the latest all the time.

if you add return true right above the function closing end, do you still get the same behaviour?