Hey guys,
I’m working on a final project for my mobile applications class, and I’ve been encountering this error when I install the apk file on my android device. My game that I’m building is based off an accelerometer. The goal of this game is to simplyt ilt the device in order to make a ball roll to a certain point, and then move onto the next level. I’m using my main, and a splash screen to complete this. I read up some things on this error already, and one of the suggestions was to check for syntax errors (spelling of variables and files and whatnot), however this doesn’t seem to be the problem. I’m not finished with this yet, but I just need to get it onto my phone to test it, as corona doesn’t support accelerometer events. Here’s my code for my main file (my splash screen is really simple, it’s just a basic intro to the game displaying the title), please let me know if you see anything that you think could cause this error! Thank you!
– tilt - o - mania
–main
local ui = require(“ui”)
local tiltSplash = require(“tiltSplash”)
local physics = require(“physics”)
physics.start()
physics.setGravity(0,0)
–basic declarations of variables
oneGroup = display.newGroup()
local ballGroup = display.newGroup()
local level = 1
tiltSplash.splash()
function loadBall()
--print(“ball loaded”)
ball = display.newImage(ballGroup, “ball.png”)
ball.x = display.contentWidth/2
ball.y = display.contentHeight/2 + 450
physics.addBody(ball, “static”, {density = 1.0, friction = 0.3, bounce = 0})
ball.myName = “ball”
--ball.alpha = 0
end
local function onTilt(event)
ball.x = ball.x - event.xGravity * 20
ball.y = ball.y - event.yGravity * 20
if(ball.x < ball.width/2) then
ball.x = ball.width/2 + 1
end
if(ball.x > ball.width - ball.width/2) then
ball.x = ball.width/2 - 1
end
if(ball.y < ball.height/2) then
ball.y = ball.height/2 + 1
end
if(ball.y > ball.height - ball.height/2) then
ball.y = ball.height/2 - 1
end
end
function loadFinish()
finishLine = display.newCircle(ballGroup, display.contentWidth/2, display.contentHeight/2 - 300, 20)
finishLine:setFillColor(255, 255, 255)
finishLine.myName = “finish”
finishLine:toFront()
physics.addBody(finishLine, “static”, {density = 0.3, friction = 0.8, bounce = 0})
end
function drawLevelOne()
finishLine.x = display.contentWidth/2
finishLine.y = display.contentHeight/2 - 450
ball.alpha = 1
wall1 = display.newRect(oneGroup, 0, 0, 180, 960)
physics.addBody(wall1, “static”, {density = 1.0, friction = 0.3, bounce = 0})
wall1:setFillColor(255,128,64)
wall2 = display.newRect(oneGroup, 360, 0, 180, 960)
physics.addBody(wall2, “static”, {density = 1.0, friction = 0.3, bounce = 0})
wall2:setFillColor(255,128,64)
obstacle1 = display.newCircle(oneGroup, 180, 250, 120)
physics.addBody(obstacle1, “static”, {density = 1.0, friction = 0.3, bounce = 1})
obstacle1:setFillColor(255,128,64)
obstacle2 = display.newCircle(oneGroup, 360, 500, 120)
physics.addBody(obstacle2, “static”, {density = 1.0, friction = 0.3, bounce = 1})
obstacle2:setFillColor(255,128,64)
obstacle3 = display.newCircle(oneGroup, 180, 780, 120)
physics.addBody(obstacle3, “static”, {density = 1.0, friction = 0.3, bounce = 1})
obstacle3:setFillColor(255,128,64)
end
function drawLevelTwo()
end
function startGame()
--print(“game has started”)
tiltSplash.dismissSplash()
loadBall()
loadFinish()
drawLevelTwo()
end
function drawNextLevel()
if level == 2 then
drawLevelTwo()
end
end
local function onCollision(event)
if((event.object1.myName == “finish” and event.object2.myName == “ball”) or (event.object1.myName == “ball” and event.object2.myName == “finish”)) then
print(“done!”)
level = level + 1
drawNextLevel()
end
end
–startGame()
tiltSplash.fadeText:addEventListener(“tap”, startGame)
system.setAccelerometerInterval(65)
Runtime:addEventListener(“accelerometer”, onTilt)
Runtime:addEventListener(“collision”, onCollision)
also if you have any questions with the code, just let me know