HTML5 textfield positionning problem


There seems to be a problem when placing text field objects in HTML5

It simply does not obey the x and y positions

The build is perfect with iOS and Android, but when building to HTML5 … text fields shifts down in y position…

You just hard code a value and substract it from the original value to position it how you want

When you set width and height to the default 320X480 it works fine, but if you change it to something like 1080X1920 it simply shifts

What is happening?

I have attached a sample code … keep in mind to change config.lua between the 2 dimensions (67.2 KB)

Actually I just noticed something else, i modified config.lua to be 1280X1920 and it worked fine, as if the ratio has always to be 320/480 which is 0.66667

1 Like

Hey @kakula …Were you able to fix the y position for the text in html5 builds?

i used this code in config.lua and all works fine

local normalW, normalH = 1280, 1920

if not display then return end -- This is needed for dekstop app

-- This calculation extends the standard letterbox scaling
-- Using this point x = 0, y = 0 is always in the top left corner of the screen on all devices
-- And x = display.contentWidth, y = display.contentHeight is always in the bottom right corner
local w, h = display.pixelWidth, display.pixelHeight
local scale = math.max(normalW / w, normalH / h)
w, h = w * scale, h * scale

application = {
    content = {
        width = w,
        height = h,
        scale = 'letterbox',
        fps = 60,
        imageSuffix = {
            ['@2x'] = 1.1,
            --['@4x'] = 2.1