I'm trying to make a card glow when it is playable by drawing a slightly bigger (correctly offset) glow image, and this works just fine when the card isn't at an angle:
But once more cards are drawn to the hand and they start to angle, this happens:
The glow image is offset by a tiny bit depending on the angle of the card for some reason, even though I'm drawing them with basically the same code, except for an offset (the glow image is 260x360, the cards are 200x300):
Code: Select all
function Card:draw()
local sprite
local x = self.x
local y = self.y
-- Check if we're offset visually
if self.showX ~= self.dxShow or self.showY ~= self.dyShow then
x = self.showX
y = self.showY
end
if self:getParent():getParent().isMine then
-- Our hand, draw the cards
sprite = self.tex_image
-- Glow if we're playable
if self.isPlayable then
local w, h = self.tex_glow:getDimensions()
local o = (w - sprite:getWidth()) / 2
love.graphics.draw(self.tex_glow, x - o / 2, y - o / 2, self.rotation, self.xscale, self.yscale, self.xpivot, self.ypivot)
end
else
-- Their hand, draw card backs
sprite = assets.images.cards['back']
end
love.graphics.draw(sprite, x, y, self.rotation, self.xscale, self.yscale, self.xpivot, self.ypivot)
end