Howdy, Stranger!

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

Codea 2.1 Universal app development problem (with potential solution)

edited December 2014 in Bugs Posts: 688

I think I've run into a problem with setting my own WIDTH & HEIGHT values in 2.1

Previously I had this code...

SIMULATED_DEVICE = {

--    {"Native",           WIDTH,HEIGHT,        ANY,FULLSCREEN, FALSE}
--    {"iPad Portrait"       768,1024, PORTRAIT_ANY,FULLSCREEN, TRUE},
    {"iPhone 4 Portrait" , 320, 480,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 5 Portrait" , 320, 568,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 6 Portrait" , 375, 667,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 6+ Portrait", 414, 736,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPad Landscape",    1024, 768,LANDSCAPE_ANY,FULLSCREEN, TRUE},
--    {"iPhone 4 Landscape", 480, 320,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 5 Landscape", 568, 320,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 6 Landscape", 667, 375,LANDSCAPE_ANY,STANDARD,   TRUE},
--    {"iPhone 6+ Landscape",736, 414,LANDSCAPE_ANY,STANDARD,   TRUE},
}

function FAKE_DEVICE(dev)

    NAME,WIDTH,HEIGHT = dev[1],dev[2],dev[3]
    supportedOrientations(dev[4])
    displayMode(dev[5])

    oneEm = WIDTH / 320
    IS_LANDSCAPE = (WIDTH > HEIGHT)
    CX,CY = WIDTH * 0.5, HEIGHT * 0.5 
    IMG_SCALAR = math.min(WIDTH,HEIGHT) / 768
end

I then call

FAKE_DEVICE(SIMULATED_DEVICE)

with the appropriate line uncommented to represent the required device.

The function was being called outside of setup() to ensure that the correct orientation setup was being called and again as the first line inside setup() to ensure the other variables were setup.

This was working in 2.0 but apparently is being ignored in 2.1

I've fixed the problem by ensuring that I only do the supportedOrientation() and displayMode() calls OUTSIDE of setup() and the rest INSIDE setup() - however I was wondering what had changed in case there's anything else I (or any other user) needs to be aware of.

Comments

  • Posts: 688

    Update : This fix works when using AirCode, but when running my code via the IDE I have to press the restart button to get the display to get updated.

    @Simeon - do you have any guidelines on how best to set the orientation / displaymode and custom WIDTH and HEIGHT settings to fit in with the new threaded model?

  • edited December 2014 Posts: 300

    Yeah I updated to 2.1 and noticed that my universal apps are acting strange now... when I set WIDTH and HEIGHT to 320x480 it acts all screwy, until I press the reset button, then it works fine. Hopefully this doesn't actually happen on devices.

  • Posts: 688

    I'm guessing it won't as you don't tend to set those on actual devices, only for dev.

Sign In or Register to comment.