try this;
// Project: Sprite Sheet Test
// Created: 2016-07-13
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Sprite Sheet Test" )
SetWindowSize( 1024, 768, 0 )
adjustScreenPercentage()
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
global lastkey as integer
global spr as integer
global img as integer
global stfrm as integer
global endfrm as integer
spr=CreateSprite(0)
img1=LoadImage("HatrixDNUPspritesheet.png") //500*800
setspritepositionbyoffset(spr,50,50)
SetSpriteImage ( spr, img1 )
SetSpriteAnimation( spr, 800/8, 500/5, 40 )
setspritesize(spr,-1,100)
SetSpriteOffset(spr,getspritewidth(spr)/2.0,getspriteheight(spr))
SetSpritePosition(spr,100,100)
stfrm=1
endfrm=20
lastkey=83
curfrm#=stfrm
//
do
GOSUB GetKeyPress
print("Frame="+str(curfrm#))
SetSpriteFrame(spr, trunc(curfrm#))
inc curfrm#, 0.5
if curfrm# > endfrm
curfrm#=stfrm
endif
// PlaySprite( spr)
Sync()
loop
GetKeyPress:
IF GetRawKeyPressed( 83 )=1 // "W" UP
stfrm=21
curfrm#=stfrm
endfrm=40
ENDIF
IF GetRawKeyPressed( 87 )=1 //"S" DOWN
stfrm=1
curfrm#=stfrm
endfrm=20
ENDIF
RETURN
function adjustScreenPercentage()
w as float
h as float
SetDisplayAspect(w/h)
endfunction