summaryrefslogtreecommitdiff
path: root/objects/Body.lua
diff options
context:
space:
mode:
Diffstat (limited to 'objects/Body.lua')
-rw-r--r--objects/Body.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/objects/Body.lua b/objects/Body.lua
index 72dbbe5..aa5bd75 100644
--- a/objects/Body.lua
+++ b/objects/Body.lua
@@ -40,10 +40,18 @@ end
function Body:draw(x, y)
if self.shape == "circle" then
- -- 绘制圆形
love.graphics.circle("fill", x, y, self.r)
elseif self.shape == "rectangle" then
- -- 绘制矩形
love.graphics.rectangle("fill", x - self.w / 2, y - self.h / 2, self.w, self.h)
end
end
+
+function Body:drawSprite(spriteName, x, y, angle)
+ local sprite = sprites[spriteName]
+ local w, h = (self.shape == "circle" and self.r or self.w), (self.shape == "circle" and self.r or self.h)
+
+ love.graphics.draw(sprite, x, y, angle,
+ w / sprite:getWidth(),
+ h / sprite:getHeight()
+ )
+end