The book suggests a state machine to direct the behaviors of the player (jumping, walking, climbing, falling, etc.) and subsequently to draw the proper sprites for each respective state. My parent object of all the player states,"oPlayer", holds all of the sprite drawing in its draw event. From the drag-and-drop directions in the book, I converted things into GML and it looks like the following:
if(facing = FACE_RIGHT)
{
if(state = PSTATE_STAND) draw_sprite(sPStandR,-1,x,y);
if(state = PSTATE_WALK) draw_sprite(sPWalkR,-1,x,y);
if(state = PSTATE_JUMP) draw_sprite(sPJumpR,-1,x,y);
if(state = PSTATE_FALL) draw_sprite(sPFallR,-1,x,y);
if(state = PSTATE_CLING) draw_sprite(sPClingR,-1,x,y);
if(state = PSTATE_CLIMB) draw_sprite(sPClimbR,-1,x,y);
}
if(facing = FACE_LEFT) //
{
if(state = PSTATE_STAND) draw_sprite(sPStandL,-1,x,y);
if(state = PSTATE_WALK) draw_sprite(sPWalkL,-1,x,y);
if(state = PSTATE_JUMP) draw_sprite(sPJumpL,-1,x,y);
if(state = PSTATE_FALL) draw_sprite(sPFallL,-1,x,y);
if(state = PSTATE_CLING) draw_sprite(sPClingL,-1,x,y);
if(state = PSTATE_CLIMB) draw_sprite(sPClimbL,-1,x,y);
}
So for example, if facing = FACE_RIGHT (because the player has hit the right key) and state = PSTATE_JUMP (becuase the player hit space) the game draws the appropriate jumping sprite. Of all the sprites, the sPClimb & sPWalk sprites are animated and contain more than one frame, however they never animate when the player hits the respective state, they just sit frozen in frame 0 of those sprites instead.
I have no idea what's going wrong. I tried to include "image_speed = 0.4" in the draw events as a means of persuading the sprites to move, but they still don't. Aside from the GML/drag-and-drop difference, I'm pretty sure my code is identical to the tutorials (the first half of which can be seen below), but while my animated sprites work in the tutorial demo files they never work in mine.
This is driving me absolutely crazy, so if anyone has any ideas of any stupid mistakes I'm making, let me know please!











