https://dl.dropboxusercontent.com/u/62302305/error.png
Here is the code:
Code: Select all
object = {}
object.__index = object
function object.create(x, y, rot, height, width, r, g, b, static, density, sticky)
local o = {}
setmetatable(o, object)
o.color = {}
o.x = x*scaleX
o.y = y*scaleY
o.rot = rot
o.image = image
o.height = height*scaleY
o.width = width*scaleX
o.sticky = sticky
o.color.r = r
o.color.g = g
o.color.b = b
if static == true then
o.body = love.physics.newBody(world, o.x, o.y, "static")
else
o.body = love.physics.newBody(world, o.x, o.y, "dynamic")
end
o.body:setAngle(math.rad(rot))
o.shape = love.physics.newRectangleShape(0, 0, o.width, o.height, o.body:getAngle())
o.fixture = love.physics.newFixture(o.body, o.shape, density)
return o
end
function object:draw()
local r,g,b,a = love.graphics.getColor()
love.graphics.setColor(self.color.r, self.color.g, self.color.b)
love.graphics.polygon("fill", self.body.getWorldPoints(self.shape:getPoints()))
love.graphics.setColor(r, g, b, a)
end
function object:applyForce(xf, yf)
self.body:applyForce(xf, yf)
end