Taming the Fire
The 20px menubar at the bottom of the screen is a permanent fixture on the Kindle Fire. The problem is that Corona includes this in the reported screen size, which can result in display objects being partially hidden if they’re positioned at the bottom.
In this post I’ll show you how you can deal with this. It works well with dynamic scaling and also screen orientation changes.
What I do is scale the stage to take the menubar into account, and shift the stage up. The benefit of doing this is that you don’t have to implement separate positioning for the Kindle Fire. You just use your normal coordinate system to place your objects, and use this snippet to scale everything down so that the menubar will not cover anything at the bottom of the screen.
Since the stage is uniformly scaled, I also recalculate the left/right visible screen coordinates accordingly.
Here’s the code:
local deviceScreen =
left = display.screenOriginX,
top = display.screenOriginY,
right = display.contentWidth - display.screenOriginX,
bottom = display.contentHeight - display.screenOriginY
-- kindle fire 20px bar-fix
if (system.getInfo("model") == "Kindle Fire") then
local kFireScale = 580 / 600;
local stage = display.getCurrentStage();
local stageShift = 10 * display.contentScaleY; -- shift the stage by half the bar height
local screenWidth = deviceScreen.right - deviceScreen.left;
local xShift = ((screenWidth / kFireScale) - screenWidth) / 2;
-- shift stage up
stage.yOrigin = stage.yOrigin - stageShift;
stage.yReference = stage.yReference + stageShift;
-- adjust left and right visible coordinates
deviceScreen.left = deviceScreen.left - xShift;
deviceScreen.right = deviceScreen.right + xShift;