Hi, I am newbie in corona. Currently i working on some app but it doesn’t work on mobile after i convert into apk and install in mobile. The app can run smoothly in emulator in the laptop. Can anyone help me solve this problem?
The usual reason for “It runs on the simulator but doesn’t on the device” is a file name case sensitivity problem. Devices are case sensitive, the simulator is not. Look for any file names where you reference it with different capital/lower case letters than the file is really named.
Also see: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/
The reason for the app not working is most likely listed in those messages.
Rob
Hi, Rob. The problem listed in those messages, I already solve it and the apk can run in my device. But only the first page can run, while the rest of the page can’t run at all.
Thank you.
Then you need to look in your console log messages for more errors. You can also put “print” statements in your code printing out messages to where you got to, print out values of key variables and try to track down where you’re crashing.
No one on the forums can provide you any help with out a) seeing your code (and you need to narrow it down to where the problem may be) or b) knowing what’s going on.
You have to provide a better description of the problem, what version of Corona SDK you’re running? What OS are you using to build on? What device and version of Android are you testing on?
We need details.
Rob
Hi Rob,
okey, then i will give you the code. The version of Corona SDK that i using now is CoronaSDK-2014.2393 with Window 7 and test with Samsung S3 with Android version 4.3. The problem that i facing now is the apk can run on the device for the menu selection page but the image and sound on the rest of page are gone and only the background is show for sebutan ABC page.
main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local storyboard = require "storyboard" -- load scenetemplate.lua storyboard.gotoScene( "mainmenu" ) -- Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc.):
mainmenu.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local tapChannel,tapSound ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- function playgame1( event ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end function playgame2( event ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan phonetics ABC","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect("background/UI 1.png", 1370,768) background.x = display.contentWidth/2 background.y = display.contentHeight/2 group:insert(background) game1 = display.newImageRect( "button/button1.png", 300,109) game1.x = display.contentWidth/2 game1.y = display.contentHeight\* 7/12 group:insert(game1) game2 = display.newImageRect( "button/button2.png", 300,109) game2.x = display.contentWidth/2 game2.y = display.contentHeight\* 9/12 group:insert(game2) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text -- audio game1:addEventListener ("touch", playgame1) game2:addEventListener ("touch", playgame2) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
sebutan ABC.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local w , h = display.viewableContentWidth , display.viewableContentHeight ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local function returnmainmenu( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu","slideRight") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function info1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function left1( event ) if event.phase == "ended" then end end local function right1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC \_b","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function a1( event ) audio.play( tapSound1 ) end local function chicken1( event ) audio.play( tapSound2 ) end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") tapSound1 = audio.loadStream("sound/reading/alphabet/a.mp3") tapSound2 = audio.loadStream("sound/reading/word/chicken.mp3") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect( "background/UI\_sebutanABC.png", 1370,768) background.x = w/2 background.y = h/2 group:insert(background) mainmenu = display.newImageRect( "button/home.png", 120,120) mainmenu.x = w/30 mainmenu.y = h\* 22/24 group:insert(mainmenu) info = display.newImageRect( "button/info.png", 120,120) info.x = w/6.0 info.y = h\* 22/24 group:insert(info) left = display.newImageRect( "button/previous-1.png", 120,120) left.x = w/3.35 left.y = h\* 22/24 group:insert(left) right = display.newImageRect( "button/next.png", 120,120) right.x = w/2.3 right.y = h\* 22/24 group:insert(right) a = display.newImageRect( "image/Combine/Aa.png",348,250) a.x = w/4 a.y = h/3 group:insert(a) chicken = display.newImageRect( "image/image\_word/chicken.png",282,413) chicken.x = w/1.6 chicken.y = h/1.6 group:insert(chicken) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text -- audio audio.play(tapSound1) audio.play(tapSound2) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) mainmenu:addEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) info:addEventListener ("touch", info1) left:removeEventListener ("touch", left1) left:addEventListener ("touch", left1) right:removeEventListener ("touch", right1) right:addEventListener ("touch", right1) a:removeEventListener ("touch", a1) a:addEventListener ("touch", a1) chicken:removeEventListener ("touch", chicken1) chicken:addEventListener ("touch", chicken1) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) left:removeEventListener ("touch", left1) right:removeEventListener ("touch", right1) a:removeEventListener ("touch", a1) chicken:removeEventListener ("touch", chicken1) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) audio.stop() -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
sebutan phonetics ABC.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local w , h = display.viewableContentWidth , display.viewableContentHeight ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local function returnmainmenu( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu","slideRight") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function info1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function left1( event ) if event.phase == "ended" then end end local function right1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC \_b","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect( "background/UI\_sebutanABCphonetic.png", 1370,768) background.x = w/2 background.y = h/2 group:insert(background) mainmenu = display.newImageRect( "button/home.png", 120,120) mainmenu.x = w/30 mainmenu.y = h\* 22/24 group:insert(mainmenu) info = display.newImageRect( "button/info.png", 120,120) info.x = w/6.0 info.y = h\* 22/24 group:insert(info) left = display.newImageRect( "button/previous-1.png", 120,120) left.x = w/3.35 left.y = h\* 22/24 group:insert(left) right = display.newImageRect( "button/next.png", 120,120) right.x = w/2.3 right.y = h\* 22/24 group:insert(right) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) mainmenu:addEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) info:addEventListener ("touch", info1) left:removeEventListener ("touch", left1) left:addEventListener ("touch", left1) right:removeEventListener ("touch", right1) right:addEventListener ("touch", right1) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) left:removeEventListener ("touch", left1) right:removeEventListener ("touch", right1) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
The usual reason for “It runs on the simulator but doesn’t on the device” is a file name case sensitivity problem. Devices are case sensitive, the simulator is not. Look for any file names where you reference it with different capital/lower case letters than the file is really named.
Also see: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/
The reason for the app not working is most likely listed in those messages.
Rob
Hi, Rob. The problem listed in those messages, I already solve it and the apk can run in my device. But only the first page can run, while the rest of the page can’t run at all.
Thank you.
Then you need to look in your console log messages for more errors. You can also put “print” statements in your code printing out messages to where you got to, print out values of key variables and try to track down where you’re crashing.
No one on the forums can provide you any help with out a) seeing your code (and you need to narrow it down to where the problem may be) or b) knowing what’s going on.
You have to provide a better description of the problem, what version of Corona SDK you’re running? What OS are you using to build on? What device and version of Android are you testing on?
We need details.
Rob
Hi Rob,
okey, then i will give you the code. The version of Corona SDK that i using now is CoronaSDK-2014.2393 with Window 7 and test with Samsung S3 with Android version 4.3. The problem that i facing now is the apk can run on the device for the menu selection page but the image and sound on the rest of page are gone and only the background is show for sebutan ABC page.
main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local storyboard = require "storyboard" -- load scenetemplate.lua storyboard.gotoScene( "mainmenu" ) -- Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc.):
mainmenu.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local tapChannel,tapSound ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- function playgame1( event ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end function playgame2( event ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan phonetics ABC","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect("background/UI 1.png", 1370,768) background.x = display.contentWidth/2 background.y = display.contentHeight/2 group:insert(background) game1 = display.newImageRect( "button/button1.png", 300,109) game1.x = display.contentWidth/2 game1.y = display.contentHeight\* 7/12 group:insert(game1) game2 = display.newImageRect( "button/button2.png", 300,109) game2.x = display.contentWidth/2 game2.y = display.contentHeight\* 9/12 group:insert(game2) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text -- audio game1:addEventListener ("touch", playgame1) game2:addEventListener ("touch", playgame2) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
sebutan ABC.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local w , h = display.viewableContentWidth , display.viewableContentHeight ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local function returnmainmenu( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu","slideRight") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function info1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function left1( event ) if event.phase == "ended" then end end local function right1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC \_b","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function a1( event ) audio.play( tapSound1 ) end local function chicken1( event ) audio.play( tapSound2 ) end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") tapSound1 = audio.loadStream("sound/reading/alphabet/a.mp3") tapSound2 = audio.loadStream("sound/reading/word/chicken.mp3") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect( "background/UI\_sebutanABC.png", 1370,768) background.x = w/2 background.y = h/2 group:insert(background) mainmenu = display.newImageRect( "button/home.png", 120,120) mainmenu.x = w/30 mainmenu.y = h\* 22/24 group:insert(mainmenu) info = display.newImageRect( "button/info.png", 120,120) info.x = w/6.0 info.y = h\* 22/24 group:insert(info) left = display.newImageRect( "button/previous-1.png", 120,120) left.x = w/3.35 left.y = h\* 22/24 group:insert(left) right = display.newImageRect( "button/next.png", 120,120) right.x = w/2.3 right.y = h\* 22/24 group:insert(right) a = display.newImageRect( "image/Combine/Aa.png",348,250) a.x = w/4 a.y = h/3 group:insert(a) chicken = display.newImageRect( "image/image\_word/chicken.png",282,413) chicken.x = w/1.6 chicken.y = h/1.6 group:insert(chicken) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text -- audio audio.play(tapSound1) audio.play(tapSound2) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) mainmenu:addEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) info:addEventListener ("touch", info1) left:removeEventListener ("touch", left1) left:addEventListener ("touch", left1) right:removeEventListener ("touch", right1) right:addEventListener ("touch", right1) a:removeEventListener ("touch", a1) a:addEventListener ("touch", a1) chicken:removeEventListener ("touch", chicken1) chicken:addEventListener ("touch", chicken1) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) left:removeEventListener ("touch", left1) right:removeEventListener ("touch", right1) a:removeEventListener ("touch", a1) chicken:removeEventListener ("touch", chicken1) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) audio.stop() -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
sebutan phonetics ABC.lua
---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local w , h = display.viewableContentWidth , display.viewableContentHeight ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local function returnmainmenu( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu","slideRight") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function info1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("mainmenu") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end local function left1( event ) if event.phase == "ended" then end end local function right1( event ) tapChannel = audio.pause( tapSound1 ) tapChannel = audio.pause( tapSound2 ) tapChannel = audio.play( tapSound ) storyboard.gotoScene("sebutan ABC \_b","slideLeft") if event.phase == "ended" then tapChannel = audio.pause( tapSound ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view tapSound = audio.loadStream("sound/tapsound.wav") ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. background = display.newImageRect( "background/UI\_sebutanABCphonetic.png", 1370,768) background.x = w/2 background.y = h/2 group:insert(background) mainmenu = display.newImageRect( "button/home.png", 120,120) mainmenu.x = w/30 mainmenu.y = h\* 22/24 group:insert(mainmenu) info = display.newImageRect( "button/info.png", 120,120) info.x = w/6.0 info.y = h\* 22/24 group:insert(info) left = display.newImageRect( "button/previous-1.png", 120,120) left.x = w/3.35 left.y = h\* 22/24 group:insert(left) right = display.newImageRect( "button/next.png", 120,120) right.x = w/2.3 right.y = h\* 22/24 group:insert(right) ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view storyboard.removeAll() ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) --colour of text --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) mainmenu:addEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) info:addEventListener ("touch", info1) left:removeEventListener ("touch", left1) left:addEventListener ("touch", left1) right:removeEventListener ("touch", right1) right:addEventListener ("touch", right1) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) --return to mainmenu event listener mainmenu:removeEventListener ("touch", returnmainmenu) info:removeEventListener ("touch", info1) left:removeEventListener ("touch", left1) right:removeEventListener ("touch", right1) ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene