EvilLemons
EvilLemons

Reputation: 13

Corona simulator anchor points Y

I can't tell if I'm doing something silly or if there is a bug in Corona simulator. When I write the following code:

rect = display.newRect(0, 0, 100, 100)
rect.anchorX = 0
rect.anchorY = 0
rect.x = 0
rect.y = 0

This just sets the anchor point of a 100x100 square to its top left, and sets the position to 0,0. This should make the square snug in the corner, but instead it produces this. It is always a little too far down in the Y axis, but the X axis functions correctly. Does anyone have a fix for this?

Upvotes: 0

Views: 80

Answers (1)

ldurniat
ldurniat

Reputation: 1702

With my Corona simulator (build 2016.2992) code works as expected.

main.lua

---------------------------------------------

local rect = display.newRect( 0, 0, 100, 100)
rect.anchorX = 0
rect.anchorY = 0

First of all check your config.lua file. I think it depends on display resolution. For example, in letterbox mode you may have "black bars" on devices with aspect ratios that differ from your content aspect ratio. Read more on Corona documentation.

Below is code from my config.lua file I'm using

config.lua

---------------------------------------------

--calculate the aspect ratio of the device
local aspectRatio = display.pixelHeight / display.pixelWidth
application = {
   content = {
      width = aspectRatio >= 1.5 and 800 or math.floor( 1200 / aspectRatio ),
      height = aspectRatio <= 1.5 and 1200 or math.floor( 800 * aspectRatio ),
      scale = "letterBox",
      fps = 30,

      imageSuffix = {
         ["@2x"] = 1.3,
      },
   },
}

Upvotes: 1

Related Questions