2015年4月1日 星期三

[Corona SDK] How to set scale in config.lua - depicted in the real case

In [Corona SDK] How to set scale in config.lua?, we show the meaning of scale in config.lua
Now we will show how it works in real cases.
Not only the parameters of width,height and scale, but the size of picture will affect the final result.
Besides, the resolution of phone you select in Corona Simulator "View As" will also decide how the result be.

Assume that the size of original picture is 320x480:

1. Set scale as "none"

width = 320,
height = 480,
scale = "none"
View As 320 x 480
View As 640 x 960
View As 1080 x 1920
View As 1920 x 1080
In this case, the aspect of the original picture is the same as the initial canvas.
The content will be completed for all resolutions, though it may be stretched for some cases.
Actually, the result is similar with zoomStretch.

2. Set scale as "letterbox"?

width = 320,
height = 480,
scale = "letterbox"
View As 320 x 480
View As 640 x 960
View As 1080 x 1920
View As 1920 x 1080
In the case of 320x480 and 640x960, the content are completed without stretched since their aspect ratios are the same.
In the case of 1080x1920, there have black bars on top/bottom sides. It is because its aspect ratio is different from 320x480. After scale up, its behavior is like that we put the 320x480 picture on the 320x568 canvas.
In the case of 1920x1080, there have black bars on left/right sides. It is because its aspect ratio is different from 320x480. After scale up, its behavior is like that we put the 320x480 picture on the 853x480 canvas.

3. Set scale as zoomEven?
width = 320,
height = 480,
scale = "zoomEven"
View As 320 x 480
View As 640 x 960
View As 1080 x 1920
View As 1920 x 1080
Similarly,in the case of 320x480 and 640x960, the content are completed without stretched since their aspect ratios are the same.
In the case of 1080x1920, the content of left/right sides are cut off. It is because its aspect ratio is different from 320x480. After scale up, its behavior is like that we put the 320x480 picture on the 270x480 canvas.
In the case of 1920x1080, tthe content of top/bottom sides are cut off. It is because its aspect ratio is different from 320x480. After scale up, its behavior is like that we put the 320x480 picture on the 320x180 canvas.

4. Set scale as zoomStretch
width = 320,
height = 480,
scale = "zoomStretch"
View As 320 x 480
View As 640 x 960
View As 1080 x 1920
View As 1920 x 1080
In the case of 320x480 and 640x960, the content are completed without stretched since their aspect ratios are the same as 320x480.
In the case of 1080x1920 and 1920x1080, the content are completed with stretched since their aspect ratios are different from 320x480.

What if the size of original picture is not 320x480?
That is, its aspect ratio is different from the width/height setting in config.lua?
If so, we need to take the ratio of original picture into our calculation process.

To summarize it....
If the picture is just used for background and the aspect ratio is not important, set the scale to be zoomStretch.
If the aspect of content is import and you can accept being cut off, set scale to be zoomEven.
If the aspect of content is import and you can accept black bars,  set scale to be letterbox.
If the aspect of content is import and you cannot accept being cut off or black bars, then you need to prepare more than one pictures with different aspect ratios.

沒有留言:

張貼留言