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:1937 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
相关文章
Webview : Is it possible to return data from the view to the App?
Download Annoying Pig Game for Android - Please Download for FREE
Adobe Illustrator Class, Photoshop Class - Online
Runtime error 'nil' with unusable stack trace
Photo Camera trouble Corona 319 (media.show(media.Camera, onComplete))
Tech support, HELP, please!
How To Disable UI Button -- Please Help
gps- within-a-range detection
Thoughts on creating a Flash version of game for marketing
Spawn Balloons
Download Annoying Pig Game for Android - Please Download for FREE
Adobe Illustrator Class, Photoshop Class - Online
Runtime error 'nil' with unusable stack trace
Photo Camera trouble Corona 319 (media.show(media.Camera, onComplete))
Tech support, HELP, please!
How To Disable UI Button -- Please Help
gps- within-a-range detection
Thoughts on creating a Flash version of game for marketing
Spawn Balloons
corona forums © 2003-2011