within my code i have a new alien being created each level and added to my alien.length. my issue is that my first alien created works with the movement and setting the animation, any after that are created move but do not play the animation for the 'climb' case. All aliens move and animate correctly if nto in the "climb" state.
function alienbmove()
for i = 0 to alienb.length
print(alienb[i].state_last)
print(alienb[i].state_now)
if alienb[i].active = 1 and alienb[i].froze = 0
alienb[i].x = getspritex(alienb[i].id)
alienb[i].y = getspritey(alienb[i].id)
dummyb[i].x = GetSpriteX ( dummyb[i].id)
dummyb[i].y = GetSpriteY( dummyb[i].id)
SetSpritePosition(alienb[i].hpbarback, Getspritex(alienb[i].id),getspritey(alienb[i].id))
SetSpritePosition(alienb[i].hpbarfront,Getspritex(alienb[i].id),getspritey(alienb[i].id))
if alienb[i].dead=0 and GetSpriteCollision(dummyp.id,dummyb[i].id) =0
if dummyb[i].x > getspritex(player.id) and GetSpriteAngle(alienb[i].id) <> 100
dummyb[i].x=dummyb [i].x - alienb[i].speed
endif
if dummyb[i].x < getspritex(player.id) and GetSpriteAngle(alienb[i].id) <> 100
dummyb[i].x=dummyb[i].x +alienb[i].speed
endif
if dummyb[i].x < getspritex(player.id)+ 200
if dummyb[i].y > dummyp.y and GetSpriteAngle(alienb[i].id) <> 100
dummyb[i].y=dummyb[i].y -alienb[i].speed
endif
if dummyb[i].y < dummyp.y and GetSpriteAngle(alienb[i].id) <> 100
dummyb[i].y=dummyb[i].y +alienb[i].speed
endif
endif
///get new state////
if alienb[i].oldx > alienb[i].x and alienb[i].oldy = alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'left'
endif
if alienb[i].oldx > alienb[i].x and alienb[i].oldy > alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'left_up'
endif
if alienb[i].oldx > alienb[i].x and alienb[i].oldy < alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'left_down'
endif
if alienb[i].oldx < alienb[i].x and alienb[i].oldy = alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'right'
endif
if alienb[i].oldx < alienb[i].x and alienb[i].oldy > alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'right_up'
endif
if alienb[i].oldx < alienb[i].x and alienb[i].oldy < alienb[i].y and alienb[i].y > getspritey(road[0].id)-120
alienb[i].state_now = 'right_down'
endif
if GetSpriteCollision(dummyb[i].id,dummyp.id)=1
alienb[i].state_now = 'atk'
endif
if alienb[i].y < getspritey(road[0].id)-120 and alienb[i].oldx <> alienb[i].x
alienb[i].state_now = 'climb'
endif
endif
/// set animation for new position
if alienb[i].state_now <> alienb[i].state_last
select alienb[i].state_now
case 'top':
endcase
case 'right_up':
SetSpriteFlip(alienb[i].id,1,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'right_up'
endcase
case 'right':
SetSpriteFlip(alienb[i].id,1,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'right'
endcase
case 'right_down':
SetSpriteFlip(alienb[i].id,1,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'right_down'
endcase
case 'down':
endcase
case 'left_down':
SetSpriteFlip(alienb[i].id,0,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'left_down'
endcase
case 'left':
SetSpriteFlip(alienb[i].id,0,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'left'
endcase
case 'left_up':
SetSpriteFlip(alienb[i].id,0,0)
PlaySprite(alienb[i].id,30,1,1,16)
alienb[i].state_last = 'left_up'
endcase
case 'atk':
SetSpriteFlip(alienb[i].id,0,0)
PlaySprite(alienb[i].id,30,1,17,28)
alienb[i].state_last = 'atk'
endcase
case 'climb':
SetSpriteFlip(alienb[i].id,0,0)
PlaySprite(alienb[i].id,30,1,28,36)
alienb[i].state_last = 'climb'
endcase
endselect
endif
SetSpritePosition(dummyb[i].id,dummyb[i].x,dummyb[i].y)
setspriteposition(alienb[i].id,dummyb[i].x,dummyb[i].y)
alienb[i].oldx = alienb[i].x
alienb[i].oldy = alienb[i].y
endif
if GetSpritePlaying(alienb[i].id)=0 and alienb[i].state_now = 'climb'
PlaySprite(alienb[i].id,30,1,28,36)
endif
next i
endfunction
note that this code was added after and is the only way ive gotten the animation to work correctly and i shouldnt need it
if GetSpritePlaying(alienb[i].id)=0 and alienb[i].state_now = 'climb'
PlaySprite(alienb[i].id,30,1,28,36)
endif