How to do sprite animations?

Simple sprite animation in an object can be done by changing the sprite_index when appropriate.

For example, in a platformer, you would switch between jump/walk/idle sprite animations like this:

var _grounded = place_meeting(x, y + 1, oGround);

if (!_grounded) {
    sprite_index = sPlayer_Jump;
}
else if (moveX != 0) {
    sprite_index = sPlayer_Walk;
}
else {
    sprite_index = sPlayer_Idle;
}