Hi, the buttons in my application doesn’t shown after convert to apk. Can anyone help me have a look on the code? i need your help. Thank you.
Here my code.
main.lua
--------------------------------------------------------------------------------- -- -- main.lua -- --------------------------------------------------------------------------------- -- hide the status bar display.setStatusBar( display.HiddenStatusBar ) -- require the composer library local composer = require "composer" -- load scene1 composer.gotoScene( "scene1" ) -- Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc)
screen1.lua
--------------------------------------------------------------------------------- -- -- scene.lua -- --------------------------------------------------------------------------------- local sceneName = ... local composer = require( "composer" ) -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view -- Called when the scene's view does not exist local bg = display.newImageRect( "background/UI 1.png", 1400, 768 ) bg.x = 515 bg.y = 385 sceneGroup: insert( bg) -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then -- Called when the scene is now on screen -- -- INSERT code here to make the scene come alive -- e.g. start timers, begin animation, play audio, etc -- we obtain the object by id from the scene's object hierarchy local phonics = display.newImageRect( "button/button1.png", 283, 98 ) phonics.x = 450 phonics.y = 450 if phonics then -- touch listener for the button function phonics:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene2", { effect = "slideLeft", time = 150 } ) end end -- add the touch event listener to the button phonics:addEventListener( "touch", phonics ) sceneGroup: insert( phonics ) end local phonetics = display.newImageRect( "button/button2.png", 283, 98 ) phonetics.x = 450 phonetics.y = 600 if phonetics then -- touch listener for the button function phonetics:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene2", { effect = "fade", time = 300 } ) end end -- add the touch event listener to the button phonetics:addEventListener( "touch", phonetics ) sceneGroup: insert( phonetics ) end end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene -- e.g. stop timers, stop animation, unload sounds, etc.) elseif phase == "did" then -- Called when the scene is now off screen end end function scene:destroy( event ) local sceneGroup = self.view if phonetics then phonetics:removeSelf() phonetics = nil elseif phonics then phonics:removeSelf() phonics = nil end -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
screen2.lua
--------------------------------------------------------------------------------- -- -- scene.lua -- --------------------------------------------------------------------------------- local sceneName = ... local composer = require( "composer" ) -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view -- Called when the scene's view does not exist local bg = display.newImageRect( "background/UI\_sebutanABC.png", 1400, 768 ) bg.x = 515 bg.y = 385 sceneGroup: insert( bg) -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then -- Called when the scene is now on screen -- -- INSERT code here to make the scene come alive -- e.g. start timers, begin animation, play audio, etc -- we obtain the object by id from the scene's object hierarchy local belajar = display.newImageRect( "button/belajar.png", 283, 98 ) belajar.x = 300 belajar.y = 500 if belajar then -- touch listener for the button function belajar:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene3", { effect = "slideLeft", time = 150 } ) end end -- add the touch event listener to the button belajar:addEventListener( "touch", belajar ) sceneGroup: insert( belajar ) end local bermain = display.newImageRect( "button/bermain.png", 283, 98 ) bermain.x = 700 bermain.y = 600 if bermain then -- touch listener for the button function bermain:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene3", { effect = "fade", time = 300 } ) end end -- add the touch event listener to the button bermain:addEventListener( "touch", bermain ) sceneGroup: insert( bermain ) end end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene -- e.g. stop timers, stop animation, unload sounds, etc.) elseif phase == "did" then -- Called when the scene is now off screen end end function scene:destroy( event ) local sceneGroup = self.view if belajar then belajar:removeSelf() belajar = nil elseif bermain then bermain:removeSelf() bermain = nil end -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
screen3.lua
--------------------------------------------------------------------------------- -- -- scene.lua -- --------------------------------------------------------------------------------- local sceneName = ... local composer = require( "composer" ) -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view -- Called when the scene's view does not exist local bg = display.newImageRect( "background/UI\_sebutanABC.png", 1400, 768 ) bg.x = 515 bg.y = 385 sceneGroup: insert( bg) -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then -- Called when the scene is now on screen -- -- INSERT code here to make the scene come alive -- e.g. start timers, begin animation, play audio, etc -- we obtain the object by id from the scene's object hierarchy local aButton = display.newImageRect( "image/Combine/Aa.png",348,250 ) aButton.x = 300 aButton.y = 250 if aButton then -- touch listener for the button function aButton:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene2", { effect = "slideLeft", time = 150 } ) end end -- add the touch event listener to the button aButton:addEventListener( "touch", aButton ) sceneGroup: insert( aButton ) end local chicken = display.newImageRect( "image/image\_word/chicken.png",282,413 ) chicken.x = 700 chicken.y = 500 if chicken then -- touch listener for the button function chicken:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene2", { effect = "slideLeft", time = 150 } ) end end -- add the touch event listener to the button chicken:addEventListener( "touch", chicken) sceneGroup: insert( chicken ) end local home = display.newImageRect( "button/home.png", 80, 80 ) home.x = 85 home.y = 720 if home then -- touch listener for the button function home:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene1", { effect = "slideLeft", time = 150 } ) end end -- add the touch event listener to the button home:addEventListener( "touch", home ) sceneGroup: insert( home ) end local bermain = display.newImageRect( "button/previous-1.png", 80, 80) bermain.x = 175 bermain.y = 720 if bermain then -- touch listener for the button function bermain:touch ( event ) local phase = event.phase if "ended" == phase then end end -- add the touch event listener to the button bermain:addEventListener( "touch", bermain ) sceneGroup: insert( bermain ) end local next = display.newImageRect( "button/next.png", 80, 80 ) next.x = 265 next.y = 720 if next then -- touch listener for the button function next:touch ( event ) local phase = event.phase if "ended" == phase then composer.gotoScene( "scene1", { effect = "fade", time = 300 } ) end end -- add the touch event listener to the button next:addEventListener( "touch", next ) sceneGroup: insert( next ) end end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene -- e.g. stop timers, stop animation, unload sounds, etc.) elseif phase == "did" then -- Called when the scene is now off screen end end function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene