Hi, I am trying to replicate a flashlight effect for my top view game.
I got this code working ok
local pd <const> = playdate
local gfx <const> = playdate.graphics
class('Night').extends(gfx.sprite)
function Night:init(player)
self.player = player
self.shadeImage = gfx.image.new(400, 240, gfx.kColorBlack)
self.shadeImage:addMask()
self:setImage(self.shadeImage)
self:setSize(400, 240)
self:setCenter(0,0)
self:moveTo(0, 0)
self:setZIndex(100)
self:add()
end
function Night:update()
local shadeMask = self.shadeImage:getMaskImage()
self.shadeImage:clearMask(1)
gfx.pushContext( shadeMask )
gfx.fillCircleAtPoint( self.player.posx, self.player.posy, 50)
gfx.popContext()
end
this code creates a black image except for the player position in a radius of 50. But I want that the black image is not black, I want a blurred or faded image, but nothing works for me, I tested with:
gfx.image.new(400, 240, gfx.kColorBlack):blurredImage(0,0 ,50, 2, playdate.graphics.image.kDitherTypeBayer8x8)
with
self.shadeImage = self.shadeImage:blurredImage(0,0 ,50, 2, playdate.graphics.image.kDitherTypeBayer8x8)
but nothing works. What am I doing wrong?
Thanks so much