NimNom1234
Member
Okay
So another member of this forum helped me with my problem a day or two ago. I feel his instructions were helpful but i did something wrong. Im trying to get my character to play through his attack animation once at the press of the space bar. However, every time i press the space bar, he just jitters and plays the first frame of the animation. This is all the code that has to do with that.
if keyboard_check_pressed(vk_right){
direction=1
}
if keyboard_check_pressed(vk_left){
direction=2
}
key_right = keyboard_check(vk_right)
key_left = keyboard_check(vk_left)
key_jump = keyboard_check_pressed(vk_up)
key_crouch = keyboard_check(vk_down)
attacking = keyboard_check_pressed(vk_space)
if attacking = false {
if key_right = true {
x += 4
sprite_index = spr_char_walk_right
}
if key_left = true{
x -= 4
sprite_index = spr_char_walk_left
}}
if attacking = true {
alarm[0] = 24
sprite_index = spr_char_attack_right
image_speed = .5
}
if attacking = false {
if direction = 0 && (place_meeting(x,y+1,obj_wall)) && key_right != true && key_left != true {
sprite_index = spr_char_idle_right
image_speed = .3
}
if direction = 1 && (place_meeting(x,y+1,obj_wall)) && key_right != true {
sprite_index = spr_char_idle_right
image_speed = .3
}
if direction = 2 && (place_meeting(x,y+1,obj_wall)) && key_left != true {
sprite_index = spr_char_idle_left
image_speed = .3
}
}
else {
sprite_index = spr_char_attack_right
}
//And in the alarm 0 event:
attacking = false
Can someone explain what im doing wrong? Thanks!
So another member of this forum helped me with my problem a day or two ago. I feel his instructions were helpful but i did something wrong. Im trying to get my character to play through his attack animation once at the press of the space bar. However, every time i press the space bar, he just jitters and plays the first frame of the animation. This is all the code that has to do with that.
if keyboard_check_pressed(vk_right){
direction=1
}
if keyboard_check_pressed(vk_left){
direction=2
}
key_right = keyboard_check(vk_right)
key_left = keyboard_check(vk_left)
key_jump = keyboard_check_pressed(vk_up)
key_crouch = keyboard_check(vk_down)
attacking = keyboard_check_pressed(vk_space)
if attacking = false {
if key_right = true {
x += 4
sprite_index = spr_char_walk_right
}
if key_left = true{
x -= 4
sprite_index = spr_char_walk_left
}}
if attacking = true {
alarm[0] = 24
sprite_index = spr_char_attack_right
image_speed = .5
}
if attacking = false {
if direction = 0 && (place_meeting(x,y+1,obj_wall)) && key_right != true && key_left != true {
sprite_index = spr_char_idle_right
image_speed = .3
}
if direction = 1 && (place_meeting(x,y+1,obj_wall)) && key_right != true {
sprite_index = spr_char_idle_right
image_speed = .3
}
if direction = 2 && (place_meeting(x,y+1,obj_wall)) && key_left != true {
sprite_index = spr_char_idle_left
image_speed = .3
}
}
else {
sprite_index = spr_char_attack_right
}
//And in the alarm 0 event:
attacking = false
Can someone explain what im doing wrong? Thanks!
Last edited: