Hello! I'm trying to draw a polygon between a background (sprite) and another sprite.
If I draw the polygon after sprite.update() then the sprites appear under the polygon, and if I call draw polygon before update() then the whole polygon disappears.
I also tried putting the drawing inside setBackgroundDrawingCallback() but it won't clean the background
(also ideally I do wanna put the boat sprite behind the wave and fish in front of the wave)
I'm on Windows using SDK 1.10.0. Thanks in advance.
While there are several ways of solving this, my favorite is to simply make everything a sprite. Do it with the polygon too!
Thank you! That works great for the z index! But now I'm not sure how to optimize the drawing rect now. It seems like it's updating the entire screen now. This is currently how I'm doing the image drawing
-- draw wave to a image
waterImage = gfx.image.new(400, 240)
waterSprite = gfx.sprite.new(waterImage)
-- draw dynamic waves
gfx.setScreenClipRect(0, waterHeight - waterStrength, 400, 240 - waterHeight + waterStrength)
drawWave(calcWave(100, waterHeight), gfx.kColorXOR)
-- update sprites
It's my first project in Playdate as I'm also trying to learn about the drawing so I'm not sure what I'm missing😅
You could manually set the sprite dirty rect:
playdate.graphics.sprite.addDirtyRect(x, y, width, height)
Using the bounds of your polygon: