constrainCameraToScreen only works on iphone 4

Ok, so I changed my config to use zoomEven and now the problem only presents on the iphone5.

Unless I am mistaken the problem with the zoom even approach is that it does not fit well with scaling policies based on the magic formula presented by corona sdk. (we no longer have a safe area to work with and therefore cannot easily consider the design for usability purposes, .e design for content that absolutely must be on screen on all devices)

the problem also presents on all of the Android devices in the simulator :S. It occurs (in my case) when the camera scrolls to the bottom of the map. (there is a gap of varying width, dependent upon device used)

What is the size of your map? Did you change xAlign to “left” and yAlign to “top”?

oops, I had omitted the xAlign, yAlign values. After changing to left and top as suggested the “problem” disappears in both zoomEven and letter box scale modes. example “working” config:

After changing to left and top as suggested the “problem” disappears in the zoomEven scale mode. 

application = {

    content = {

        width = 320,

        height = 480, 

        scale = “letterBox”,

        fps = 30,

        xAlign= “left”,

                yAlign= “top”,

        

        imageSuffix = {

            ["@2x"] = 2,

                    ["@4x"] = 4,

                    

        }

        

    },

    --[[

    – Push notifications

    notification =

    {

        iphone =

        {

            types =

            {

                “badge”, “sound”, “alert”, “newsstand”

            }

        }

    }

    --]]    

}

Thanks.

/s

The problem still occurs with letterbox scaling. MTE really needs to support letterBox Scaling as this is the method deployed by all of the recommended configurations.

as far as i am aware letterbox scaling is the only method that allows us to work to  set dimensions for UI design. It allows us to work to a fixed 320*480 window that is guaranteed to be visible across all devices irrespective of  pixel ratio;

the problem with zoomEven is that on different ratios, some of the content from the 320x480 rect can go offscreen. What if some important content goes offscreen? The game becomes unplayable! With letterbox you guarantee that nothing inside that rect goes offscreen, so you have a region in which you can base your game, and you’re sure that no matter how strange the ratio may be, it can even be 1000:1, nothing important will ever be offscreen.

see: 

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

http://forums.coronalabs.com/topic/19174-understanding-letterbox-scalling/

supporting the  following config would give the ideal results:

application = {
    content = {
        width = 320,
        height = 480,
        scale = “letterbox”,
        xAlign = “center”,
        yAlign = “center”,
    }
}

Is it just that the following values need to be accounted for in some of the calculations?: 

Top:
local topY = display.screenOriginY

Right:
local rightX = display.contentWidth - display.screenOriginX

Bottom:
local bottomY = display.contentHeight - display.screenOriginY

Left:
local rightX = display.screenOriginX

 

 

best,

S

I have another solution for you to try.

Go into mte.lua and navigate down to the constrainCameraToScreen function. Replace these lines:

masterConstrainTop = ((display.viewableContentHeight \* 0.5) / map.layers[refLayer].properties.scaleY ) + (blockScaleY \* 0.5) masterConstrainBottom = mapHeight - (((display.viewableContentHeight \* 0.5) / map.layers[refLayer].properties.scaleY ) - (blockScaleY \* 0.5)) masterConstrainLeft = ((display.viewableContentWidth \* 0.5) / map.layers[refLayer].properties.scaleX ) + (blockScaleX \* 0.5) masterConstrainRight = mapWidth - (((display.viewableContentWidth \* 0.5) / map.layers[refLayer].properties.scaleX ) - (blockScaleX \* 0.5))

-with these lines. Note the addition/subtraction of display.screenOriginY or display.screenOriginX at the end of each line. 

masterConstrainTop = ((display.viewableContentHeight \* 0.5) / map.layers[refLayer].properties.scaleY ) + (blockScaleY \* 0.5) - (display.screenOriginY) masterConstrainBottom = mapHeight - (((display.viewableContentHeight \* 0.5) / map.layers[refLayer].properties.scaleY ) - (blockScaleY \* 0.5)) + (display.screenOriginY) masterConstrainLeft = ((display.viewableContentWidth \* 0.5) / map.layers[refLayer].properties.scaleX ) + (blockScaleX \* 0.5) - (display.screenOriginX) masterConstrainRight = mapWidth - (((display.viewableContentWidth \* 0.5) / map.layers[refLayer].properties.scaleX ) - (blockScaleX \* 0.5)) + (display.screenOriginX)

In your config.lua file, set xAlign and yAlign to “center” if you haven’t already. In my tests this keeps the view filled (if the map is large enough) and always shows a safe, as-large-as-possible 480x320 region centered on the screen.

Something to keep in mind is this; if you have a 15 x 10 tile map and you set blockScale to 32, the entire map will be smaller than the size of the screen. It will be nicely centered in the screen, but if your map isn’t large enough there simply won’t be content available to fill the space. This is actually what I thought you were talking about, at first! 

Let me know how the fix works for you.

this seems to fix the issue on everything bar iphone5.

So there is still a very large gap on the iphone 5.

btw ime using mte 0v872, the reason for this is that the fix/hack that used to allow offscreen movement for sprites does not work in latest version.

oops, looks like i failed to change the config scale policy to letterBox

Just a heads up, I’m releasing a patch on Friday which, among other things, adds a constrainToMap parameter to addSprite, moveSpriteTo, and moveSprite, for controlling whether a sprite can leave the map. 

got feature that we urgently need, it may relate to this see new topic (unmanaged sprites)