A
Alexander Olofsson
Guest
So yeah, title basically says it all, I've set a key to trigger an attack animation, but it won't work, I have an idle animation, running anim, jumping etc. I'm thinking the idle and running animations are screwing up, and if they do, any way to make a line of code to stop the anim whilst attacking? Here's the code;
Step Event above. Tried key press & key release, animation end, will still not work.
Oh, if I forgot to tell you, I started with coding yesterday. I can a bit of coding, but I'm still improving and trying to learn!
Code:
//Platform Physics
var rkey = keyboard_check(ord('D'));
var lkey = keyboard_check(ord('A'));
var jkey = keyboard_check(vk_space);
var akey = keyboard_check(ord('F'));
//Check for ground, it's useful.
if (place_meeting(x, y+1, obj_solid)) {
vspd = 0;
//Jumping
if (jkey) {
vspd = - jspd;
}
} else {
//You need gravity to use your legs and jump, run n stuff.
if (vspd < 10) {
vspd += grav;
}
}
//Want to use your legs?
if (rkey) {
hspd = spd
}
if (lkey) {
hspd = -spd;
}
//Wanna know if you're moving or not? Well here you go. (check if moving)
if ((!rkey && !lkey) || (rkey && lkey)) {
hspd = 0;
}
//Attack Animation (not working?( I've watched dozens of videos, still not working));
if (akey) {
sprite_index = spr_attack;
image_speed = 1
}
//Don't know how to run without moving a single limb in your body? Well, here's a fix for that. (Sprite anims)
if (rkey || lkey) {
sprite_index = spr_running;
image_speed = 0.2;
} else {
sprite_index = spr_stand;
image_speed = 0.08
}
if (!place_meeting( x, y+1, obj_solid)) {
sprite_index = spr_jumping;
image_speed = 0;
}
//Don't want to be running backwards? Well here's the fix to that. (Look in other dircetions)
if (rkey) {
image_xscale = 1;
} else if (lkey) {
image_xscale = -1;
}
Oh, if I forgot to tell you, I started with coding yesterday. I can a bit of coding, but I'm still improving and trying to learn!