So i have searched in the forums and seen in the past that corona cannot communicate with the hardware buttons on android phones, i just wanted to double check and see if that is still the case? If that is the case, im wondering if there is any possibility of disabling the "back" button. Because with the way things currently are when people push the back button or the home button, it just exits the app completely. Any info would be great thanks
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Android still has no control with hardware buttons?
The newest release of Corona "does" support the Android buttons via "key" events. Please see sample app "Hardware\KeyEvents" included in the Corona SDK.
Here is the API documentation...
http://developer.anscamobile.com/reference/index/events/key
glad to hear it, thank you for the quick response
So here is my code,
1 2 3 4 5 6 7 8 9 10 11 | local function onKeyEvent( event ) local returnValue = true local phase = event.phase if phase == "back" then audio.play(clickSound) end return returnValue end Runtime:addEventListener( "key", onKeyEvent ) |
nevermind i figured out what i was doing wrong, i was telling it to give me the phase rather than what button was pressed, this is how you can get both the phase and the keypress
1 2 3 4 5 6 7 8 9 10 11 | local function onKeyEvent( event ) local returnValue = true local phase = event.phase local whatKey = event.keyName if whatKey == "back" and phase == "down" then audio.play(clickSound) return returnValue end Runtime:addEventListener( "key", onKeyEvent ) |
Great! I'm glad it's working for you!
views:1651 update:2011/10/8 8:54:25
热门文章
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
相关文章
I think I am regressing
Chocolat- New text editor invites!
Director \ Data Question
Please do not use "type" as a function parameter name...
Possible to copy a portion of a image and store as a sprite?
Amazon refuse to mark my app as Kindle Fire compatible
Easy Twitter integration
Build for the Nook
Building a Platform game with Corona and Lime -- Blog post
Shape problem
Chocolat- New text editor invites!
Director \ Data Question
Please do not use "type" as a function parameter name...
Possible to copy a portion of a image and store as a sprite?
Amazon refuse to mark my app as Kindle Fire compatible
Easy Twitter integration
Build for the Nook
Building a Platform game with Corona and Lime -- Blog post
Shape problem
corona forums © 2003-2011