Button Counter

I am making a pitch counter and am wondering what a counting code would look like? I can’t seem to get my numbers to add and continue to add [import]uid: 26968 topic_id: 7689 reply_id: 307689[/import]

Just put in your button function

btnClick = btnClick + 1 [import]uid: 11809 topic_id: 7689 reply_id: 27294[/import]

Something like this:

[lua]local counter = 0

– declared here so it can be referenced in button’s event handler
local label

local button = display.newCircle( 160, 240, 40 )
button:setFillColor( 0, 255, 0 )
button:addEventListener( ‘touch’, function( e )
if e.phase == ‘began’ then
button:setFillColor( 255, 255, 0 )
counter = counter + 1
label.text = ‘#’…counter
elseif e.phase == ‘ended’ or e.phase == ‘cancelled’ then
button:setFillColor( 0, 255, 0 )
end
end )

– created here so it will appear on top of the button
label = display.newText( ‘#0’, 0, 0, native.systemFont, 24 )
label:setTextColor( 0, 0, 0 )
label:setReferencePoint( display.CenterReferencePoint )
label.x = 160; label.y = 240[/lua] [import]uid: 32962 topic_id: 7689 reply_id: 27303[/import]

It’s for a pitch counter, and I need the number to keep on being displayed [import]uid: 26880 topic_id: 7689 reply_id: 27875[/import]