Here's how I would probably do it. My game 'Backlash' uses a similar technique.
My Game due for release on AppUp very soon:
Backlash-Ninja Training
My Code for your sprite:
Rem Project: cleric
Rem Created: Tuesday, February 08, 2011
Rem ***** Main Source File *****
sync on : sync rate 0 : autocam off
position camera 0,0,-100
point camera 0,0,0
load image "ClericWhite.bmp", 1
split_image(1,4,4,11,rgb(255, 0, 255))
make object plane 1, 48, 64
set object transparency 1,1
tex=19
texture object 1,tex
do
rem text
center text screen width()/2,0,"Use Arrowkeys to walk"
rem Get user input
u=upkey()
r=rightkey()
d=downkey()
l=leftkey()
previnpt=inpt
inpt=u+r+d+l
rem edit animation state based on input
if inpt<>0
if previnpt<>inpt
anim=0
endif
else
sti=20 : fni=20
endif
if timer()>anim
anim=timer()+200
if u : sti=11 : fni=14 : endif
if r : sti=15 : fni=18 : endif
if d : sti=19 : fni=22 : endif
if l : sti=23 : fni=26 : endif
inc tex
if tex<sti then tex=sti
if tex>fni then tex=sti
endif
texture object 1,tex
sync
loop
function split_image(image as integer, numX as integer, numY as integer, start as integer, colourkey)
if colourkey<>0 then set image colorkey rgbr(colourkey), rgbg(colourkey), rgbb(colourkey)
iw=image width(image)
ih=image height(image)
create bitmap 1,iw,ih
set current bitmap 1
paste image image,0,0,0
w#=iw/numX
h#=ih/numY
i=start
for y=1 to numY
for x=1 to numX
sx#=(x-1)*w#
sy#=(y-1)*h#
get image i,sx#,sy#,sx#+w#,sy#+h#,1
inc i
next x
next y
set current bitmap 0
endfunction
