Hi Folks,
My apologies in advance if this is an easy solution and I am being really dosile!
I am simply trying to implement a user controlled score counter, using a few widget buttons. I have the button widgets in the scene:create section and the fucntions in the scene accessible code area. Nothing is happening
Any help will be greatly appreciated.
Code:
local function scoreIncrease( string )
if ( string == “minusP1” ) then
print(“pressed = P1-”)
if ( scoreP1 > 0 ) then
scoreP1 = scoreP1 - 1
end
elseif ( string == “plusP1” ) then
print(“pressed = P1+”)
if ( scoreP1 < 10 ) then
scoreP1 = scoreP1 + 1
end
elseif ( string == “minusP2” ) then
print(“pressed = P2-”)
if ( scoreP2 > 0 ) then
scoreP2 = scoreP2 - 1
end
elseif ( string == “plusP2” ) then
print(“pressed = P2+”)
if ( scoreP2 < 10 ) then
scoreP2 = scoreP2 + 1
end
end
end
function scene:create( event )
local sceneGroup = self.view
minusP1= widget.newButton{
label="-",
fontSize=130,
labelColor = { default={ 0, 0, 0 }, over={ 0, 0, 0, 0.5 } },
labelXOffset = -2,
labelYOffset = -14,
defaultFile=“content/btn1.png”,
overFile=“content/btn1Over.png”,
width=200, height=200,
onRelease = scoreIncrease( “minusP1” )
}
minusP1.x = display.contentCenterX - 175
minusP1.y = display.contentCenterY + 25
plusP1= widget.newButton{
label="+",
fontSize=130,
labelColor = { default={ 0, 0, 0 }, over={ 0, 0, 0, 0.5 } },
labelXOffset = -2,
labelYOffset = -4,
defaultFile=“content/btn1.png”,
overFile=“content/btn1Over.png”,
width=200, height=200,
onRelease = scoreIncrease( “plusP1” )
}
plusP1.x = display.contentCenterX + 175
plusP1.y = display.contentCenterY + 25
minusP2= widget.newButton{
label="-",
fontSize=130,
labelColor = { default={ 0, 0, 0 }, over={ 0, 0, 0, 0.5 } },
labelXOffset = -2,
labelYOffset = -14,
defaultFile=“content/btn2.png”,
overFile=“content/btn2Over.png”,
width=200, height=200,
onRelease = scoreIncrease( “minusP2” )
}
minusP2.x = display.contentCenterX - 175
minusP2.y = display.contentCenterY + 225
plusP2= widget.newButton{
label="+",
fontSize=130,
labelColor = { default={ 0, 0, 0 }, over={ 0, 0, 0, 0.5 } },
labelXOffset = -2,
labelYOffset = -4,
defaultFile=“content/btn2.png”,
overFile=“content/btn2Over.png”,
width=200, height=200,
onRelease = scoreIncrease( “plusP2” )
}
plusP2.x = display.contentCenterX + 175
plusP2.y = display.contentCenterY + 225
All the best,
Alex