Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to fix coordinate offset
Started by eto_ru Nov 07 2018 09:17 AM

3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

eto_ru

[GLOBAL: userInfoPane.html]
eto_ru
  • Observer

  • 17 posts
  • Corona SDK

File main.lua

display.setStatusBar(display.HiddenStatusBar)

local composer  = require( "composer" )

display.setStatusBar(display.HiddenStatusBar)

display.setDefault( "anchorX", 0 )
display.setDefault( "anchorY", 0 )
display.setDefault( "isAnchorClamped", true )

composer.gotoScene( "maps" )

File maps.lua

local composer 	= require ( "composer" )
local scene = composer.newScene()
 
local ID = system.getInfo( "deviceID" )
 
function scene:create( event )
 
    local sceneGroup = self.view
--
-- Начало сцены Maps.lua
-- 
 
local background = display.newImage( "maps.png" )
sceneGroup:insert ( background )
 
--
-- Конец сцены Maps.lua
-- 
end
 
scene:addEventListener( "create",  scene )
return scene

When loading, the area remains at the top and the coordinates are shifted by 42 units.

How to fix this defect?

 

Attached Files



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,286 posts
  • Corona SDK

That is not a defect.  You need to understand how scaling works on different devices. <0,0> is not necessarily the top-left for all devices.

 

Have you read: https://docs.coronalabs.com/guide/basics/configSettings/index.html

 

1. Red that guide first.

 

2.  See this example where I show how to calculate the edges of the screen and full width and height regardless of the device.  Also, look at the basic config.lua that comes with the project:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/10/lgg4.zip

 

lgg4.png



[TOPIC: post.html]
#3

eto_ru

[GLOBAL: userInfoPane.html]
eto_ru
  • Observer

  • 17 posts
  • Corona SDK

Большое спасибо. 

Thank you very much.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,860 posts
  • Corona Staff

Some other important additional reading on the subject: https://coronalabs.com/blog/2018/08/08/understanding-content-scaling-in-corona/

 

Rob


  • roaminggamer likes this


[topic_controls]
[/topic_controls]