0
votes

I'm fairly new to Lua and Corona SDK but so far I'm finding everything very enjoyable. I've been following a tutorial to create a small mobile app game using Corona. It needed a lot of images to be centered so I decided to write the following function to center images.

local function centering(img)
    local centerX = display.contentcenterX
    local centerY = display.contentcenterY
    local img = img
    img.x = centerX; img.y = centerY
    return img
end

local obj1 = display.newImage("obj1.png")
local obj2 = display.newImage("obj2.png")
local obj3 = display.newImage("obj3.png")

local img_list = {obj1, obj2, obj3}
for i = 1, #img_list do
    centering(img_list[i])
end

Everything seems to compile without errors. However, the images aren't in the center of the screen. What am I doing wrong? Any Lua or Corona SDK advice is gladly appreciated.

1
This is a typo, don't see any value in such question. Please delete. - Oliver

1 Answers

1
votes

contentCenterX and contentCenterY should be with capital letter C for center.