I’ve created a simple test program (below) that runs fine in the simulator, but after compiling, placing the apk on a website and downloading to a real device (Samsung Galaxy 4, Android 4.3), the app shows the border, but does not respond to the tap event and display the balloons. Corona v2013.2076.
What am I missing?
local physics = require(“physics”)
physics.start()
physics.setGravity( 0, -.01 )
_G.w = display.contentWidth
_G.h = display.contentHeight
_G.centerX = w/2
_G.centerY = h/2
_G.scaleX = 1/display.contentScaleX
_G.scaleY = 1/display.contentScaleY
_G.displayWidth = (display.contentWidth - display.screenOriginX*2)
_G.displayHeight = (display.contentHeight - display.screenOriginY*2)
_G.unusedWidth = _G.displayWidth - _G.w
_G.unusedHeight = _G.displayHeight - _G.h
_G.deviceWidth = math.floor((displayWidth/display.contentScaleX) + 0.5)
_G.deviceHeight = math.floor((displayHeight/display.contentScaleY) + 0.5)
print("\n************************************************* " )
print("\nDesign Specs")
print("------------")
print(" design width (w) = " … w)
print(" design height (h) = " … h)
print("x-axis center (centerX) = " … centerX)
print("y-axis center (centerY) = " … centerY)
print("\nDevice Specs")
print("------------")
print(" device width (deviceWidth) = " … deviceWidth)
print("device height (deviceHeight) = " … deviceHeight)
print("\nDesign --> Device Scaling")
print("-------------------------")
print("content scale X (scaleX) = " … math.floor(scaleX,3))
print("content scale Y (scaleY) = " … math.floor(scaleY,3))
print("\nVisible scaled screen")
print("---------------------")
print(" displayWidth = " … displayWidth)
print("displayHeight = " … displayHeight)
print("\nUnused scaled pixels")
print("--------------------")
print(" unusedWidth = " … unusedWidth)
print("unusedHeight = " … unusedHeight)
print("\nScreen Orientation")
print("------------------")
print(system.orientation )
print("\n************************************************* \n" )
local borderTop = display.newRect(0,0,display.contentWidth*2, 32)
borderTop.x = display.contentWidth
borderTop.y = display.contentHeight-display.contentHeight
borderTop.myName = “Border Top”
local borderBottom = display.newRect(0,0,display.contentWidth*2, 32)
borderBottom.x = display.contentWidth
borderBottom.y = display.contentHeight
borderBottom.myName = “Border Bottom”
local borderLeft = display.newRect(0,0,32, display.contentHeight*2)
borderLeft.x = display.contentWidth-display.contentWidth
borderLeft.y = display.contentHeight
borderLeft.myName = “Border Left”
local borderRight = display.newRect(0,0,32, display.contentHeight*2)
borderRight.x = display.contentWidth
borderRight.y = display.contentHeight
borderRight.myName = “Border Right”
physics.addBody(borderTop,“static”,{density=3, bounce=1.0005})
physics.addBody(borderBottom,“static”,{density=3, bounce=1.0005})
physics.addBody(borderLeft,“static”,{density=3, bounce=.8})
physics.addBody(borderRight,“static”,{density=3, bounce=.8})
local bloons=nil
local BloonsPerRow = 4
local BloonsPerCol = 6
local bloonWidth = (deviceWidth / BloonsPerRow) - 30
local bloonHeight = (deviceHeight / BloonsPerCol) - 30
local bloonXScale = bloonWidth / 100
local bloonYScale = bloonHeight / 150
local bloonCount = BloonsPerRow * BloonsPerCol
function doBalloons()
local i = 0
for i = 1, bloonCount do
index = i
bloons[index] = display.newImage( “BlueBalloon.png” )
bloons[index]:scale( bloonXScale, bloonYScale )
--bloons[index].anchorX=0
--bloons[index].anchorY=0
--bloons[index].x = (i-1) * bloonWidth + borderLeft.contentWidth
--bloons[index].y = (j-1) * bloonHeight + borderTop.contentHeight
bloons[index].x = display.contentWidth/2 + math.random(0, 10)
bloons[index].y = display.contentHeight/2 + math.random(0, 200)
bloons[index].myName = "Balloon " … index
--print( “Width=” … bloonWidth … “, Scale=” … bloonXScale )
--print( “Bloon width=” … bloons[index].contentWidth )
BloonShape={0,-bloonWidth/2, -bloonHeight/2,0, 0,bloonWidth/2, bloonHeight/2,0 }
physics.addBody(bloons[index], { bodyType=dynamic, density=3, friction=0, bounce=1, radius=bloonHeight/2})
end --for
end
function killBalloons()
print( “Killing Balloons” )
local i = 0
for i = 1, bloonCount do
index = i
if not (bloons[index]) then
print( “Bad” );
else
print( "Removing " … bloons[index].myName )
physics.removeBody(bloons[index])
end
bloons[index]:removeSelf()
bloons[index] = nil
end --for
bloons=nil
end
local function onCollision( event )
if ( event.phase == “began” ) then
--print( "began: " … event.object1.myName … " & " … event.object2.myName )
elseif ( event.phase == “ended” ) then
--print( "ended: " … event.object1.myName … " & " … event.object2.myName )
end
end
local function onTouch( event )
if ( event.phase == “began” ) then
if(bloons) then
killBalloons()
end
elseif ( event.phase == “ended” ) then
bloons={}
doBalloons()
end
return true
end
Runtime:addEventListener( “collision”, onCollision )
Runtime:addEventListener( “touch”, onTouch )