Hi! I wanted to know if a real Playdate can handle something like 150 draw functions at a time, while nothing else very important is happening in the game. The idea is to use a player tile with transparency to make a fade-to-black animation like this:
Also doing this example I've seen there is a delay between "deleting" the fade out and going to another room
This is the code in the teleport item
on collect do
ignore
fadeOutAnimation = 1
wait 2 then
fadeOutAnimation = 2
wait 0.5 then
goto 5,7 in "room2"
fadeOutAnimation = 0
fadeOut_animReset = 0
tell event.player to
swap "player"
end
listen
end
end
end
This is the code in the player's draw
if fadeOutAnimation==1 then
if fadeOut_animReset==0 then
play "tile_fadeOut"
fadeOut_animReset = 1
end
drawCount = 0
drawX = 4
drawY = 0
while drawCount<=152 do
draw "tile_fadeOut" at drawX,drawY
drawCount++
drawX++
if drawX==21 then
drawX = 4
drawY++
end
end
elseif fadeOutAnimation==2 then
fill "black" at 32,0,136,72
end
But anyway this problem can be solved by changing those "reseting" variables in the enter of the next room and works fine, like this:
on enter do
fadeOutAnimation = 0
fadeOut_animReset = 0
tell event.player to
swap "player"
end
end
Also it seems to have the same delay if I put exactly that in the exit event instead.
First of all, knowing about the performance of multiple draw calls is important. Some games might require a lot of objects on screen, like bullets.
For your problem in particular, it looks like you are fading with a repeating pattern. Would something like a single large area drawTiled() call work? You might need to usa a solid color image and setMaskImage() to your fade pattern.