diff --git a/examples/complex.lua b/examples/complex.lua index 8a174a9..cfc4824 100644 --- a/examples/complex.lua +++ b/examples/complex.lua @@ -195,11 +195,11 @@ function love.update(dt) if phyLight[i]:getType() == "polygon" then phyLight[i]:setPoints(phyBody[i]:getWorldPoints(phyShape[i]:getPoints())) elseif phyLight[i]:getType() == "circle" then - phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY()) + phyLight[i]:setPosition(phyBody[i]:getPosition()) elseif phyLight[i]:getType() == "image" then - phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY()) + phyLight[i]:setPosition(phyBody[i]:getPosition()) elseif phyLight[i]:getType() == "refraction" then - --phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY()) + --phyLight[i]:setPosition(phyBody[i]:getPosition()) end end if phyLight[i]:getType() == "refraction" then @@ -367,7 +367,8 @@ function drawForground(l,t,w,h) elseif phyLight[i]:getType() == "circle" then math.randomseed(i) love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255)) - love.graphics.circle("fill", phyLight[i]:getX(), phyLight[i]:getY(), phyLight[i]:getRadius()) + local cx, cy = phyLight[i]:getPosition() + love.graphics.circle("fill", cx, cy, phyLight[i]:getRadius()) elseif phyLight[i]:getType() == "image" then if normalOn and phyLight[i].normal then love.graphics.setColor(255, 255, 255) diff --git a/examples/short.lua b/examples/short.lua index c165352..f2686c3 100644 --- a/examples/short.lua +++ b/examples/short.lua @@ -134,7 +134,8 @@ end function drawForground(l,t,w,h) love.graphics.setColor(63, 255, 127) - love.graphics.circle("fill", circleTest:getX(), circleTest:getY(), circleTest:getRadius()) + local cx, cy = circleTest:getPosition() + love.graphics.circle("fill", cx, cy, circleTest:getRadius()) love.graphics.polygon("fill", rectangleTest:getPoints()) love.graphics.setColor(255, 255, 255) love.graphics.draw(image, 64 - image:getWidth() * 0.5, 64 - image:getHeight() * 0.5) diff --git a/lib/body.lua b/lib/body.lua index 9cb52f5..fea2a87 100644 --- a/lib/body.lua +++ b/lib/body.lua @@ -109,30 +109,9 @@ function body:setPosition(x, y) end end --- set x position -function body:setX(x) - if x ~= self.x then - self.x = x - self:refresh() - end -end - --- set y position -function body:setY(y) - if y ~= self.y then - self.y = y - self:refresh() - end -end - -- get x position -function body:getX() - return self.x -end - --- get y position -function body:getY(y) - return self.y +function body:getPosition() + return self.x, self.y end -- get width