I am trying to make a simple game similar to BreakOut Mania for iPad to practice with the Physics Engine before I make my own game. I added a global event listener to turn on physics when the user taps the screen anywhere, but when I run the app on an iPad in the simulator, the Corona Simulator “has quit unexpectedly” any time I try to click. Also, none of my blocks appear. My code is below. Originally, I also had a collision listener for the ball, but I deleted this and the problem of crashing persists. I am not sure if this is my fault or if it’s a bug with Corona. I have the latest version of Corona for a non-subscriber.
[code]
–Ball & Paddle
local midx=display.contentWidth/2
local ballRadius=20
local ball = display.newCircle(midx, display.contentHeight-35, ballRadius)
ball:setFillColor (0,200,200)
local paddleWidth=100
local paddle = display.newRoundedRect(midx-paddleWidth/2, display.contentHeight-10, paddleWidth, 10, 3)
paddle:setFillColor(100,100,100)
–Blocks
local blockWidth, blockHeight = 80, 50
local blockY = 50
local blockColor = 0,200,0
local blockStrokeColor = 255,255,255
local block1 = display.newRect(170,blockY, blockWidth, blockHeight)
block1:setFillColor(blockColor)
block1:setStrokeColor(blockStrokeColor)
local block2 = display.newRect(260,blockY, blockWidth, blockHeight)
block2:setFillColor(blockColor)
block2:setStrokeColor(blockStrokeColor)
local block3 = display.newRect(350,blockY, blockWidth, blockHeight)
block3:setFillColor(blockColor)
block3:setStrokeColor(blockStrokeColor)
local block4 = display.newRect(440,blockY, blockWidth, blockHeight)
block4:setFillColor(blockColor)
block4:setStrokeColor(blockStrokeColor)
local block5 = display.newRect(530,blockY, blockWidth, blockHeight)
block5:setFillColor(blockColor)
block5:setStrokeColor(blockStrokeColor)
function physicsSetUp()
physics = require “physics”
physics.setGravity(0, 9.8)
physics.setDrawMode(normal)
physics.start(true)
physics.addBody(ball, {density=0.5, bounce=0.7, radius=ballRadius})
ball.isBullet=true
physics.addBody(paddle, “static”)
physics.addBody(block1, “kinematic”)
physics.addBody(block2, “kinematic”)
physics.addBody(block3, “kinematic”)
physics.addBody(block4, “kinematic”)
physics.addBody(block5, “kinematic”)
end
Runtime:addEventListener(“tap”, physicsSetUp)
[/code] [import]uid: 23768 topic_id: 11911 reply_id: 311911[/import]