Hi everybody,
I have built an app for an android tablet and have a problem with displaying a polygon at the correct position. Indeed, on my emulator it’s correctly displayed but on the tablet a shift appears on the y axis.
Here are the screenshot so that you see how it looks : (the polygon built is the blue shape)
Emulator app
Tablet app
Here’s the code that builds the ellipse (which is a 512 vertices polygon) :
-- local variable that describes the ellipse local ellipse = { polygon = nil, n = 512, rx = 90.0, ry = 74.0, xRelativeToImage = 1155, yRelativeToImage = 585, vertices = {} } -- function that builds the ellipse function efSceneConfigMenu:BuildEllipse(parent) print("efSceneConfigMenu:BuildEllipse") -- Coordinates (x,y) table of the polygon vertices local i = nil local j = 1 local a = nil local percent = nil if(ellipse.polygon ~= nil) then display.remove(ellipse.polygon) ellipse.polygon = nil ellipse.vertices = {} end -- we show the first no empty compartment from rear to front if(selectedPercentLiquidRight ~= 0) then percent = selectedPercentLiquidRight elseif(selectedPercentLiquidMiddle ~= 0 and selectedPercentLiquidRight == 0) then percent = selectedPercentLiquidMiddle elseif(selectedPercentLiquidLeft ~= 0 and selectedPercentLiquidMiddle == 0 and selectedPercentLiquidRight == 0) then percent = selectedPercentLiquidLeft end if(percent ~= nil) then local ymax = ellipse.ry - 2\*percent\*ellipse.ry/100 -- used to shift the polygon because its origin is the center of gravity -- and not its bottom local deltaY = (ellipse.ry - percent\*ellipse.ry/100) for i = 1, ellipse.n, 1 do a = 2\*math.pi\*(i-1)/ellipse.n if(ellipse.ry\*math.sin(a) \>= ymax) then ellipse.vertices[2\*j-1] = ellipse.rx\*math.cos(a) ellipse.vertices[2\*j] = ellipse.ry\*math.sin(a) --print(ellipse.vertices[2\*j-1] .. " ; " .. ellipse.vertices[2\*j]) j = j + 1 end end ellipse.polygon = display.newPolygon( parent, ellipse.xRelativeToImage, ellipse.yRelativeToImage + deltaY, ellipse.vertices ) ellipse.polygon:setFillColor(0, 0, 255) self.loadMenuGroupLiquid:insert(ellipse.polygon) ellipse.polygon:toBack( ) end end
Anyone would have an idea of why I have this problem so that I know where to investigate ?
Thank you