Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Black frame after Launch image in Codea Xcode project

edited April 2014 in Bugs Posts: 50

When exporting a Codea app to an Xcode project, there is a single black frame that gets displayed between the launch image and the first frame of the app. Is there a way to fix this? It's especially problematic when the launch screen is the same as the app's first frame, because you get a black flash instead of a smooth transition.

Comments

  • Posts: 2,820

    I've never seen this.

  • I just exported the empty app that gets generated when creating a new project, and it shows one black frame between the launch image and the background color from the draw() function when running it on Xcode. I assume everyone has this problem, even if you haven't seen it.

  • Posts: 136

    I have had this problem when using an IOS simulator. Are you using the simulator, or a connected device?

  • It happens on both the simulator and devices. The black flash defeats part of the purpose of having a launch image. I'm sure anyone running exported Codea apps on devices would have this problem.

  • edited April 2014 Posts: 2,820

    @SpellCollapse - Now I see it (on a slower device). You might try a method similar to StackIt: Have a black launch image and have the actual app fade in from blackness.
    If you want the black launch images, LMK.

  • I'd prefer an actual launch image, and Apple insists on one in their documentation. I've tried drawing in the setup() function and different backing modes, but nothing worked. Codea does not seem to allow drawing to the very first frame. Even if the device is fast, the black flash is unsightly.

  • Posts: 2,820

    @SpellCollapse - I don't think Apple really cares. I've seen lots of other games that do the same thing. But alright.

  • edited April 2014 Posts: 1,976

    Does a single black frame really matter?

    How could a single black frame at the beginning completely destroy the entire experience of the app?

  • edited April 2014 Posts: 50

    I really don't want to debate whether or not a black flash after the launch screen is acceptable. I'm looking for a fix.

  • I've been able to change the black frame to a different color by using a background color or a rectangle in the setup() function. But if I use a sprite, it will not draw from the setup function, so now I can get a flash of any color I want, but that is no fix.

  • Posts: 425

    You could cheat and make the app fade in after starting

  • edited April 2014 Posts: 50

    The launch image exists so that the user does not have to stare at a black screen while the app starts up. I would like to use it as it was intended. Like many apps, my app does a lot of prep work in the setup() function, so the black flash is somewhat long.

    You can download Spell Collapse Free (AppStore.com/SpellCollapseFree) if you want to see the problem in action. I can also send anyone a promo code for the paid version, Spell Collapse (AppStore.com/SpellCollapse). It is one of best rated word games on the App Store with 4.6 stars, and almost completely done in Codea.

  • edited April 2014 Posts: 50

    I also have a free app called Flighty Birds (AppStore.com/FlightyBirds), that also demonstrates the problem. This game has objects that slide onto the launch image screen, which would look amazing if there wasn't a long black flash that interrupts the effect.

  • Posts: 2,042

    @SpellCollapse, I have installed flighty birds and I see no such error. The transition is perfect, with the objects sliding onto the screen seamlessly (no interrupting black screen)

  • @JakAttack - That's strange. When you start it, there will be a blue sky and sun with the word "LOADING" as a launch screen. When the word "LOADING" disappears and the scene slides on the screen, there should be a back frame for a half/quarter second. The black frame appears on all 6 devices I have tried, and in the simulator.

  • Posts: 136

    @SpellCollapse I believe If you draw an image as the first thing in the function setup() then it will show during the black screen. Try making a background exactly the same as your loading screen. I didn't check if this works but I think it does.

  • @jrohanian - Only background() and rect() work in the setup() function, and sprite() does not work.

  • Posts: 1,976

    @SpellCollapse sprite() works fine for me in the setup function.

  • @SkyTheCoder - Was this on the iPad using Codea, or on the Mac with Xcode?

  • Posts: 136

    @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
    
    
  • Posts: 2,042

    @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.

  • Posts: 1,976

    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.

  • Posts: 2,042

    @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.

  • edited May 2014 Posts: 50

    @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
    
  • Posts: 1,595

    @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.

  • Posts: 1,595

    @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.

Sign In or Register to comment.