Hi! I’m having a problem with composer transitions. In simulator works great but in my Nexus 6 do not work at first time. When I play with my buttons tapping all of them to look how its works composer transitions start working correctly. My app have a menu with 3 widget buttons, the first one take to a heavy scene with 53 map location buttons to switch to google maps, 53 phone buttons to make a call, second one take me to a scene with 7 buttons, this 7 buttons have the same scene code to show some images in scrollView, the only change between them is the background and the images inside the scene scrollView. In the menu I have an Spanish button and an English button, Spanish is default scene when app start. When I switch to english all the scenes transitions work properly. Third menu button is under construction in another project to integrate later.
Here is the code I’m using in the 7 equal scenes in wich only the background and images inside scrollView change:
local composer = require( "composer" ) local scene = composer.newScene() local widget = require( "widget" ) -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- local background local ScrollView local glassbar1 local shoppers local backButton local paintButton local toolsButton local bulbButton local barrowButton local showerButton local hoseButton local basketButton --sound local flick local turn local here --shopper------------------------ local shopperImages = { "shopperimg1", "shopperimg2", "shopperimg3", "shopperimg4", "shopperimg5", "shopperimg6", "shopperimg7" } --shopper------------------------ local \_W = display.contentWidth local \_H = display.contentHeight local function backButtonTap () audio.play( flick ) composer.gotoScene( "scenes.en.menu\_en", {effect = "crossFade", time = "375"} ) return true end --shopper scenes local function paintButtonTap () audio.play( turn ) composer.gotoScene( "scenes.en.shopper\_en", {effect = "slideLeft", time = "370"} ) return true end local function toolsButtonTap () audio.play( turn ) composer.gotoScene( "scenes.en.ferreteria\_en", {effect = "slideLeft", time = "370"} ) return true end local function bulbButtonTap () audio.play ( turn ) composer.gotoScene( "scenes.en.electrico\_en", {effect = "slideLeft", time = "370"} ) return true end local function barrowButtonTap () audio.play ( turn ) composer.gotoScene( "scenes.en.construccion\_en", {effect = "slideLeft", time = "370"} ) return true end local function showerButtonTap () audio.play ( here ) print( "showerButton was tapped" ) return true end local function hoseButtonTap () audio.play ( turn ) composer.gotoScene( "scenes.en.plomeria\_en", {effect = "slideLeft", time = "370"} ) return true end local function basketButtonTap () audio.play ( turn ) composer.gotoScene( "scenes.en.miscelania\_en", {effect = "slideLeft", time = "370"} ) return true end -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen background = display.newImageRect( "images/background/showroombg.jpg", 768, 1024 ) background.x = display.contentCenterX background.y = display.contentCenterY sceneGroup:insert( background ) glassbar1 = display.newImageRect( "images/buttons/glassbar@2x.png", 375, 60 ) glassbar1.x = display.contentWidth-460 glassbar1.y = display.contentHeight-975 sceneGroup:insert( glassbar1 ) shoppers = display.newImageRect( "images/buttons/shoppers@2x.png", 131, 23 ) shoppers.x = display.contentWidth-460 shoppers.y = display.contentHeight-975 sceneGroup:insert( shoppers ) -- scroll view ScrollView = widget.newScrollView( { top = 100, left = 120, width = 530, height = 800, scrollWidth = 400, scrollHeight = 800, horizontalScrollDisabled = true, hideBackground = true } ) sceneGroup:insert( ScrollView ) --shopper images shopperimg1 = display.newImageRect( "images/shopper/5\_showroom/banner1.jpg", 500, 240 ) shopperimg1.x = \_W-503; shopperimg1.y = \_H-890; --sceneGroup:insert( shopperimg1 ) ScrollView:insert( shopperimg1 ) shopperimg2 = display.newImageRect( "images/shopper/5\_showroom/banner2.jpg", 500, 240 ) shopperimg2.x = \_W-503; shopperimg2.y = shopperimg1.y+250; --sceneGroup:insert( shopperimg2 ) ScrollView:insert( shopperimg2 ) shopperimg3 = display.newImageRect( "images/shopper/5\_showroom/banner3.jpg", 500, 240 ) shopperimg3.x = \_W-503; shopperimg3.y = shopperimg2.y+250; --sceneGroup:insert( shopperimg3 ) ScrollView:insert( shopperimg3 ) shopperimg4 = display.newImageRect( "images/shopper/5\_showroom/banner4.jpg", 500, 240 ) shopperimg4.x = \_W-503; shopperimg4.y = shopperimg3.y+250; --sceneGroup:insert( shopperimg4 ) ScrollView:insert( shopperimg4 ) shopperimg5 = display.newImageRect( "images/shopper/5\_showroom/banner5.jpg", 500, 240 ) shopperimg5.x = \_W-503; shopperimg5.y = shopperimg4.y+250; --sceneGroup:insert( shopperimg5 ) ScrollView:insert( shopperimg5 ) shopperimg6 = display.newImageRect( "images/shopper/5\_showroom/banner6.jpg", 500, 240 ) shopperimg6.x = \_W-503; shopperimg6.y = shopperimg5.y+250; --sceneGroup:insert( shopperimg6 ) ScrollView:insert( shopperimg6 ) shopperimg7 = display.newImageRect( "images/shopper/5\_showroom/banner7.jpg", 500, 240 ) shopperimg7.x = \_W-503; shopperimg7.y = shopperimg6.y+250; --sceneGroup:insert( shopperimg7 ) ScrollView:insert( shopperimg7 ) --shopper images -- back Button backButton = widget.newButton( { width = 57, height = 60, defaultFile = "images/buttons/back@2x.png", overFile = "images/buttons/back-over@2x.png", } ) -- Center the back button backButton.x = display.contentWidth-615 backButton.y = display.contentHeight-975 sceneGroup:insert( backButton ) backButton:addEventListener( "tap", backButtonTap ) -- paint Button paintButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/paint@2x.png", overFile = "images/buttons/paint-over@2x.png", } ) -- Center the paint button paintButton.x = \_W-615; paintButton.y = \_H-60; sceneGroup:insert( paintButton ) paintButton:addEventListener( "tap", paintButtonTap ) -- tools Button toolsButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/tools@2x.png", overFile = "images/buttons/tools-over@2x.png", } ) -- Center the tools button toolsButton.x = paintButton.x+78; toolsButton.y = \_H-60; sceneGroup:insert( toolsButton ) toolsButton:addEventListener( "tap", toolsButtonTap ) -- bulb Button bulbButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/bulb@2x.png", overFile = "images/buttons/bulb-over@2x.png", } ) -- Center the bulb button bulbButton.x = toolsButton.x+78; bulbButton.y = \_H-60; sceneGroup:insert( bulbButton ) bulbButton:addEventListener( "tap", bulbButtonTap ) -- barrow Button barrowButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/barrow@2x.png", overFile = "images/buttons/barrow-over@2x.png", } ) -- Center the barrow button barrowButton.x = bulbButton.x+78; barrowButton.y = \_H-60; sceneGroup:insert( barrowButton ) barrowButton:addEventListener( "tap", barrowButtonTap ) -- shower Button showerButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/shower-on@2x.png", overFile = "images/buttons/shower@2x.png", } ) -- Center the toilet button showerButton.x = barrowButton.x+78; showerButton.y = \_H-60; sceneGroup:insert( showerButton ) showerButton:addEventListener( "tap", showerButtonTap ) -- hose Button hoseButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/hose@2x.png", overFile = "images/buttons/hose-over@2x.png", } ) -- Center the hose button hoseButton.x = showerButton.x+78; hoseButton.y = \_H-60; sceneGroup:insert( hoseButton ) hoseButton:addEventListener( "tap", hoseButtonTap ) -- basket Button basketButton = widget.newButton( { width = 66, height = 70, defaultFile = "images/buttons/basket@2x.png", overFile = "images/buttons/basket-over@2x.png", } ) -- Center the basket button basketButton.x = hoseButton.x+78; basketButton.y = \_H-60; sceneGroup:insert( basketButton ) basketButton:addEventListener( "tap", basketButtonTap ) flick = audio.loadSound( "sound/flick.wav" ) turn = audio.loadSound( "sound/turn.wav" ) here = audio.loadSound( "sound/here.wav" ) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view shopperImages:removeSelf() shopperImages = nil audio.dispose( flick ) audio.dispose( turn ) audio.dispose( here ) end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene
My code is incorrect or misspelled?
should I insert the scrollview images in the scene too?
using too much images?
do I need to make a separate module with all my functions?
I’m using atom.
This is my first code in Corona SDK and my first post looking for help. English is not my default language but I really understand it. I hope you undestandme too.
Thanks In advance!