I don't quite understand your problem. From what I can gather, the sprite is shown and changed according to your code but they aren't animated? If so, you might want to check the image_speed of your player object.
Sorry I was unclear. It's the sprite itself that isn't showing up, despite changing the spite_index.
Sorry ChevyRay - here you go, this is the code executed inside the main's step event:
/* Physics and input code credit goes to Matt Thorson (mattmakesgames.com) */
//Friction handling
var accel, fric;
if (on_ground) {
fric = S_RUN_FRIC;
} else {
fric = S_AIR_FRIC;
}
/* OBJECT LEFT-RIGHT DETECTION */
//If solid object is immediately to the right, rNext flag true
if (place_meeting( x + 1, y, block )){
rNext = true;
//If solid object is immediately to the left, lNext flag true
}else if (place_meeting( x - 1, y, block )){
lNext = true;
}else{
rNext = false;
lNext = false;
}
/* PLAYER INPUT EVAL */
if (keyboard_check_direct( vk_right )) {
//Running right
rflag = true;
hspd = approach( 2, S_MAX_H, 0);
//Climbing to the right
if (on_ground && rNext && (keyboard_check_direct( vk_up ))){
//Set flag for display
climbing = true;
//Reposition character
x += 32;
y -= 32;
}
} else if (keyboard_check_direct( vk_left )) {
//Running left
rflag = false;
hspd = approach( -2, -S_MAX_H, 0);
} else {
//Stopping
hspd = approach( hspd, 0, fric);
}
if (on_ground) {
vflag = false;
//Jumping
if (keyboard_check_pressed( vk_up )){
vspd = S_JUMP_SPEED;
vflag = true;
}
} else {
//Gravity
vspd = approach( vspd, S_MAX_V, S_GRAVITY );
}
/* DRAWING EVAL */
//All sprites are 32 x 32, with origins at (16,16).
//Exception is climb sprite, which is 64x64, with origin at (32,32)
//This is the bit I'm having trouble with. The climb animation is the character
//scrambling up and over a 32 x 32 block
if (climbing){
sprite_index = climb;
}
if (on_ground){
//If unmoving, or if next to an object (so it doesn't keep running at walls)
if(hspd == 0 || rNext || lNext){
if (rflag){
sprite_index = amRStand;
}
else{
sprite_index = amLStand;
}
}else if((hspd > 0) && !rNext){
sprite_index = amRWalk;
}else if ((hspd < 0) && !lNext){
sprite_index = amLWalk;
}
}else{
if (rflag){
sprite_index = amRJump;
}else{
sprite_index = amLJump;
}
}
Right now, only climbing to the right is implemented. In its current state, when the character is immediately next to a block, and the player presses right and then subsequently up, the character will instantly be transported up and to the right by 32 pixels, without being changed to the climb sprite (it also continues having upward velocity, but I'll fix that later
). Right now I'm just trying to get it to display (which explains the lack of making the climbing flag false, eh heh) but finalized, the key combo will change the character sprite to the climbing sprite, and when the animation is done with, the character will change back to a standing sprite and have been moved to the final position(up and to the right by 32) that the animation indicates.
bateleur: I actually don't know what in GML will allow me to ignore key events, that is, what code will be executed if I do set a disableKey flag. The only thing I can think of is somehow setting up a timed loop (though I don't know how to do that, either -_-) with no key detection code that will start when the animation starts to play, and then stop when the animation is done.