I know this is similar to Simulator crashing for some sprite rotations, but I can't tell if it's exactly the same. In any case, it's definitely happening in 1.4.0, running on Playdate hardware.
I haven't extracted this into an example project yet, but the code is in the repo I just pushed to the Panic gitlab for Spellcorked.
Even though these are labeled "sprite", they aren't SDK Sprites. They're just cached images from a 207 x 206 px imagetable. Basically each frame the deg
increments up or down by 1, and if it's divisible by 10, I rotate the image and store it as rotSprite.
function StirringScene:rotateCreamSprite()
local deg = self.cream.rotDegrees
deg = deg + self.lastCrankDirection
-- print('rotateCreamSprite() new deg: ' .. deg)
if deg % 10 == 0 then
self.cream.rotSprite = self.cream.sprite:rotatedImage(deg)
-- print('rotateCreamSprite() saved new sprite')
end
self.cream.rotDegrees = deg
end
The crashing line is self.cream.rotSprite = self.cream.sprite:rotatedImage(deg)
. Here's the bug report:
I've done a lot of work this past week to avoid crashes caused by calling the built-in image functions in uncertain conditions. This one, I can't figure out. If these calls would fail with a warning (or return false if they fail) instead of crashing the entire app, it would make my life a lot easier!
Is there any way for me to code, "Try to rotate this image, but if it doesn't work, no big deal? Just return false and keep the old image, I don't care"?
Thanks y'all!