Help with spawning multiple objects
Posted: Mon May 18, 2020 4:13 pm
Hello, I was wondering if someone could help me out with spawning objects
I am trying to make another ball spawn once two objects collide with one another, through my 'addBalls' function (file found here):
And I call the function in the update function of my PlayState like this:
But then I get the error message: PlayState.lua:92: attempt to call method 'addBalls' (a nil value)
Any help appreciated
I am trying to make another ball spawn once two objects collide with one another, through my 'addBalls' function (file found here):
Code: Select all
balls = {}
function addBalls(x, y)
local ball = {}
ball.width = 8
ball.height = 8
ball.dy = 0
ball.dx = 0
ball.skin = skin
table.insert(balls, ball)
for ball in pairs(balls) do
love.graphics.draw(gTextures['main'], gFrames['balls'][ball.skin], ball.x, ball.y)
end
end
Code: Select all
if self.powerup:collides(self.paddle) then
powerup = false
Ball:addBalls(x,y)
end
Any help appreciated