Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

composer.loadScene acts like composer.gotoScene
Started by patrick.gerull Feb 21 2019 03:39 PM

- - - - -
No replies to this topic
composer loadscene gotoscene
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

patrick.gerull

[GLOBAL: userInfoPane.html]
patrick.gerull
  • Observer

  • 1 posts
  • Corona SDK

Hello,

first of all, I am an absolute beginner at Corona, so I guess, I just ran into some newbie-problems.

Here is the issue:

 

Because I am loading quite a few images in a scene:create-function, my app simply does not manage to display a scene transition while loading, placing and resizing those images within a for loop.

 

So my solution is, to load the scene in my "main-lua", then entering a "menue.lua" from where I finally can enter my image-heavy "ownstory.lua".

 

The problem is, instead of just loading the "ownstory.lua", the app seems to enter (or just display) the "ownstory.lua".

 

 

Simplyfied code:

 

main.lua:

local composer = require("composer")

composer.loadScene("ownstory", false)

composer.gotoScene("menue", {effect = "fade", time = 500})

because my "menue.lua" works pretty well, I jump directly into my "ownstory.lua":

local composer = require( "composer" )
 
local scene = composer.newScene()

-- variables for placing and resizing images 
local x_count = display.screenOriginX
local y_count = 0
local tilecount = 3

-- variable to access images
local img = {}

-- loading images
for n = 1, 26, 1 do
    local path = system.pathForFile( "img/tile_" .. n .. ".png", system.ResourceDirectory )
    if path ~= nil then
        print( "File exists" )
        img[n] = display.newImage("img/tile_" .. n .. ".png")
    else
        print( "File does not exist!" )
    end
end

function scene:create( event )
 
    local sceneGroup = self.view
    
    -- placing and resizing images
    for n = 1, 26, 1 do
        img[n].width = display.actualContentWidth/tilecount
        img[n].height = display.actualContentWidth/tilecount
        img[n].anchorY = 0
        img[n].anchorX = 0
        img[n].x = x_count
        img[n].y = y_count
        sceneGroup:insert(img[n])
        x_count = x_count + display.actualContentWidth/tilecount
        if x_count >= display.actualContentWidth then
            x_count = display.screenOriginX
            y_count = y_count + display.actualContentWidth/tilecount
        end
    end
end
 

I thought the composer.loadScene-function loads and hides the scene in the background - but somehow it displays the whole scene in the foreground.

 

Any ideas?

 

 

PS: In the simulator (Windows) everything runs fine, but as soon as I test on my Android phone, the trouble begins...




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: composer, loadscene, gotoscene