If you call SetSpriteAnimation() on a sprite for a second time then AppGameKit will crash - no error message, just a hard ugly crash!
My initial thought was that the sprite was animating at the time that I tried to change the frame size, so I added a StopSprite() prior to the SetSpriteAnimation() but it made no difference. It crashes regardless of whether or not the sprite is currently animating.
Small test code:
// Project: test
// Created: 2018-02-13
// show all errors
SetErrorMode(2)
// set window properties
w = 640
h = 480
SetVirtualResolution(w, h)
SetWindowSize(w, h, 0)
r = MakeColor(255, 0, 0)
g = MakeColor(0, 255, 0)
b = MakeColor(0, 0, 255)
y = MakeColor(255, 255, 0)
DrawBox(0, 0, 256, 256, r, g, b, y, 1)
Render()
img = GetImage(0, 0, 256, 256)
spr = CreateSprite(img)
SetSpriteAnimation(spr, 128, 128, 4)
SetSpritePosition(spr, 100, 100)
do
if GetRawKeyPressed(80) //Press P to play sprite
PlaySprite(spr, 30, 1)
endif
if GetRawKeyPressed(65)
StopSprite(spr)
SetSpriteAnimation(spr, 64, 64, 16) //Press A for small frames
endif
if GetRawKeyPressed(66)
StopSprite(spr)
SetSpriteAnimation(spr, 128, 128, 4) //Press B for large frames
endif
print(ScreenFPS())
if GetRawKeyState(27) then end
Sync()
loop
You can avoid the crash by calling ClearSpriteAnimationFrames() prior to calling SetSpriteAnimation() but maybe that should be standard 'behind the scenes' functionality since not caling it produces such an ugly crash.