Hey I am new to Corona and I am having a problem with giving the walls of my game collision. Its a game where you have a ball like Ping pong and slabs you have to hit with the ball and they disappear but the ball won’t bounce off the walls. This is the code I have so far for the game:
local w = display.contentWidth
local h = display.contentHeight
local physics = require(“physics”)
physics.start()
physics.setGravity(0,0)
local bg = display.newRect(w/2,h/2,w,h)
local pg = display.newRoundedRect(w/2,h-h/20,w/4,h/30,30)
pg:setFillColor(0,0,0)
physics.addBody(pg, “static”)
local function movePg(event)
pg.x = event.x
end
Runtime:addEventListener(“touch”, movePg)
local width = w/6 - w/20
local height = h/20 - h/30
for i=1,5,2 do
for j=1,11,2 do
local enemy = display.newRoundedRect(w/12*j,h/20*i,width, height,30)
enemy:setFillColor(0,0,0)
physics.addBody(enemy, “static”)
local function collision(self, event)
self:removeSelf()
end
enemy.collision = collision
enemy:addEventListener(“collision”)
end
end
local ball = display.newCircle(w/2,h/2,w/40)
ball:setFillColor(0,0,0)
physics.addBody(ball, “dynamic”, {bounce=1})
ball:setLinearVelocity(w/4, w/4)
local wallSx = display.newRect(w*w/20,h/2,w/10,h)
local wallDx = display.newRect(w*w/20,h/2, w/10, h)
physics.addBody(wallSx, “static”)
physics.addBody(wallDx, “static”)