I have an object called "entity" with a function called "entity.spawn." Inside that function the data for the x, y, sprite, and id (for multiplayer) is stored. However, when I want to add a body for my entity, I get an error when trying to attach the body to the fixture, stating,
Here's my code for that:Bad argument #1 to newFixture (Body expected, got nil)
Code: Select all
local entity = {}
entity.entities = {} --All entities
entity.spawn = function(id, x, y)
local sprites = {
blueSprite,
yellowSprite,
redSprite,
purpleSprite,
}
return {
sprite = sprites[(tonumber(id) % #sprites) + 1],
id = id,
x = x,
y = y,
body = love.physics.newBody(world, x, y, "dynamic"),
shape = love.physics.newCircleShape(50),
fixture = love.physics.newFixture(body, shape)
}
end