Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Inconsistency in the values returned by display.safeScreenOriginX/Y
Started by leokarun Mar 22 2019 04:35 AM

2 replies to this topic
display safescreenoriginx safescreenoriginy landscape portrait
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

leokarun

[GLOBAL: userInfoPane.html]
leokarun
  • Observer

  • 24 posts
  • Corona SDK

Hey there,

 

I've been using Corona sdk to develop games and am currently working on multiple projects. I've been going through the docs and came across these two variables related to display API, safeScreenOriginX and safeScreenOriginY. It says they return the distance from left and top side of "safe area" to the left and and top side of the content area respectively. This is a pretty useful feature offered by corona which comes handy while setting the placements of UI elements in the game in order to account for devices with various aspect ratios.

 

Going by the aforementioned description the values of safeScreenOriginY and safeScreenOriginX for a device has to be same. But what surprises me is that the values change when I change the orientation of the game. For instance, when I print their values in 2 different projects, one portrait and another landscape, the values are very different for the same device. To throw some more light, when I tried printing the values of safeScreenOriginY and safeScreenOriginX using an iphone 4s simulator, the values for the portrait game were 55 and -69.5 respectively and for the landscape game, 13.91 and 0 respectively. I was expecting that the values would simply get swapped when the orientation is changed from portrait to landscape but that wasn't the case. 

 

Not sure if I entirely understand what they mean by "safe area", but if someone could help me do away with this confusion, I'd be delighted : )



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,460 posts
  • Enterprise

I would suggest you read this blog post: https://coronalabs.com/blog/2018/08/08/understanding-content-scaling-in-corona/

 

In particular, the section on iPhone X weirdness explains the difference between display.screenOriginX and display.saveScreenOriginX.

 

Also, Apple has a guide for this too.  See https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/ and scroll down to the section on safe areas.

More and more devices are introducing rounded corners and sensor housing notches that you have to work your UI around.

 

Rob



[TOPIC: post.html]
#3

leokarun

[GLOBAL: userInfoPane.html]
leokarun
  • Observer

  • 24 posts
  • Corona SDK

Thanks for your response! I understood the concept of safe screen area  and how it is useful in placing UI elements in the game for devices with abnormal aspect ratios. But what I don't quite understand is how can the values of safeScreenOrigin X and Y, change for the same device when switched between portrait and landscape mode. I mean its not like the values are just swapped(which is understandable and ideally what one might expect) but are completely different as in case of iPhone4s that I had explained in my previous message.  




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: display, safescreenoriginx, safescreenoriginy, landscape, portrait