I want my characters to leave "slime trails", and so my thought was this: I'll create two canvases. Every frame, I'll flip between the two canvases, copying the "front" buffer into the "back" buffer with some small transparency multiplier. This would make anything drawn to either canvas slowly fade out.
However, I get a really weird effect where some frames it draws the slime trail at full transparency, and some frames it draws at half transparency.
Here's where I copy over the slime trails from the previous frame
Code: Select all
function CopySlimeCanvas(fromCanvas, toCanvas)
love.graphics.setCanvas(toCanvas)
love.graphics.clear()
-- Set premultiplied alpha blend mode since we've
-- already rendered the maze to canvas
love.graphics.setBlendMode("alpha", "premultiplied")
love.graphics.setColor(255, 255, 255, 0.5) -- draw the previous "back" buffer at half transparency (???)
love.graphics.draw(fromCanvas, 0, 0)
love.graphics.reset()
end
Code: Select all
function StatePlaying:drawSlimeCanvas()
love.graphics.setCanvas(self.slimeCanvases[self.currentSlimeCanvas]) -- currentSlimeCanvas switches between 1 and 2 every frame
for _, player in ipairs(self.players) do
love.graphics.setColor(255, 0, 255, 0.5) -- Draw the slime trail at half opacity
love.graphics.circle("fill", player.x, player.y, SLIME_RADIUS)
end
love.graphics.reset()
end
Thanks!
Erty