Im having trouble with my game that I am making which is like a ping pong game where when the ball touches the blocks but I keep having a problem where its saying setLinearvelocity is a nil value if anyone could help please do.
local w = display.contentWidth
local h = display.contentHeight
local fisica = require(“physics”)
fisica.start()
fisica.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)
fisica.addBody(pg, “static”)
local function movePg(event)
pg.x = event.x
end
Runtime:addEventListener(“touch”, movePg)
local larghezza = w/6 - w/20
local altezza = 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,larghezza,altezza,30)
enemy:setFillColor(0,0,0)
fisica.addBody(enemy, “static”)
local function collisione(self, event)
self:removeSelf()
end
enemy.collision = collisione
enemy:addEventListener(“collision”)
end
end
local ball = display.newCircle(w/2,h/2,w/40)
ball:setFillColor(0,0,0)
fisica.addBody(ball, “dynamic”, {bounce=1})
ball:setLinearvelocity(w/2, w/2)
local wallSx = display.newRect(w/20,h/2,w/10,h)
local wallDx = display.newRect(w*w/20,h/2, w/10, h)
fisica.addBody(wallSx, “static”)
fisica.addBody(wallDx, “static”)