Black frame after Launch image in Codea Xcode project

@SpellCollapse @SkyTheCoder Yeah I tried it, it works for me as well. That’s what I thought.

I’d like to see your code. Every time I try to draw a sprite in setup(), I only get black.

@SkyTheCoder, @jrohanian - Here is the test app that I am using to show that there is a black frame between the launch image and the app’s first frame, after exporting the project to Xcode. I am using the same image as a launch image. The call to sprite() in the setup() function is not removing the black frame. If anyone has code that works, I’d like to see it.

function setup()
    displayMode(FULLSCREEN_NO_BUTTONS)
    spriteMode(CORNER)
    sprite("Cargo Bot:Startup Screen")
end

function draw()
    sprite("Cargo Bot:Startup Screen")
end

@SpellCollapse, try putting the displayMode at the top of the code, outside of the setup function.

@JakAttak - I tried that just now and I still get the same problem.

Well, this seems to work:

function setup()
    frame = 0
    print("Setup")
end

function draw()
    frame = frame + 1
    
    if frame <= 30 then
        print("Frame #" .. frame)
    elseif frame == 31 then
        print("Frame #31...")
    end
    
    if frame == 2 then
        -- Do your setup stuff here
        x = 0
        for i = 1, 2 ^ 22 do
            x = math.sin(x) + math.cos(i)
        end
        print("X is " .. x)
    elseif frame > 2 then
        --Normal draw function stuff here
    end
    sprite("Cargo Bot:Startup Screen", WIDTH / 2, HEIGHT / 2, WIDTH, HEIGHT)
end

It draws the first frame in 1/60th of a second, and then on the second frame it runs all your long, slow, and complicated setup code. Then on frames 3+ you do all your normal draw stuff. Seems to get rid of the black frame, or at least make it last only 1/60th of a second.

@SkyTheCoder - That does not work for me. I still get a black frame. Minimizing it’s length still causes a black flash.

@SpellCollapse, I am seeing what you are saying now. I checked a couple of published Codea apps (Scramblers, Pachinkoos, Touchline, Flighty Birds) and they all do it. I don’t think there is a way around it, which is annoying because I also like to do seamless transition between launch image and app.

@JakAttak - I was able to fix the problem in Flighty Birds using your suggestion of calling displayMode() outside of setup(), although for some reason it did not fix the problem in my test app. When I also added a blank fill to my test app, it then fixed the problem. The rect() draws nothing because the alpha is set to 0. The test app now looks like this, and there is no black flash. Odd but it works.

displayMode(FULLSCREEN_NO_BUTTONS)

function setup()
    spriteMode(CORNER)
    sprite("Cargo Bot:Startup Screen")
    fill(0,0,0,0)
    rect(0,0,WIDTH,HEIGHT)
end

function draw()
    sprite("Cargo Bot:Startup Screen")
end

@SpellCollapse I doubt this is fixable with Codea unless you just do an animation or colour transition to fade from black, I never realty thought it looked that bad until I just checked it out it fades to black from the launch image then flicks from black to the first screen/image depending in your code, doesn’t look fancy.

@Luatee - I’ve been able to fix the black frame using the above hack. I’ve now fixed Flighty Birds and Spell Collapse, and it works on both the iPad and iPhones.

@SpellCollapse oh I tried that on my older project and it didn’t really change it apart from the fading process, I’ll try it on a newer exported project, thanks.