You are using
LoadImage() incorrectly. Move that outside any loop and only call it once. If you need to use the same variable to load a different image, make sure to delete the previously loaded image before loading any other image. Also, you could just use
SetSpriteImage() instead of deleting the sprite and recreating it every time you need to change sprite images.
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test" )
SetWindowSize( 720, 405, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 720, 405 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 1 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// set print properties
SetPrintSize( 26 )
SetPrintColor( 255, 255, 0 )
global hat_imgID as integer
global axe_imgID as integer
global sprID as integer
global spot1t as integer = 1
// Load images once.
hat_imgID = LoadImage( "icon_1.png" )
axe_imgID = LoadImage( "icon_2.png" )
// Create sprite once.
sprID = CreateSprite( hat_imgID )
do
// Change the sprite's image when needed.
if GetPointerPressed()
inc spot1t
if spot1t > 2 then spot1t = 1
NewIcon()
endif
PrintC( "FPS: " ) : Print( Str( ScreenFPS(), 0 ) )
Sync()
loop
Function NewIcon()
if spot1t = 1
SetSpriteImage( sprID, hat_imgID )
elseif spot1t = 2
SetSpriteImage( sprID, axe_imgID )
endif
Endfunction