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
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Button Counter
Just put in your button function
btnClick = btnClick + 1
Something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 |
It's for a pitch counter, and I need the number to keep on being displayed
views:1938 update:2011/9/18 14:43:09
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
Load screen and loaders on Android
SDK Proxy Access
native.newVideo() are listeners working yet?
Native Game Center Tutorial
Clear All Lines
Slots From The Crypt: PROMO CODES
In App Purchases - Universal Binary - What Devices? - Nook?
iPad SDK?
Install failed on Kindle Fire
Mask help, need to change touch area
SDK Proxy Access
native.newVideo() are listeners working yet?
Native Game Center Tutorial
Clear All Lines
Slots From The Crypt: PROMO CODES
In App Purchases - Universal Binary - What Devices? - Nook?
iPad SDK?
Install failed on Kindle Fire
Mask help, need to change touch area
corona forums © 2003-2011