Hi - I'm having trouble programming a sprite to use different animations at different phases of its attack. Sometimes it works, sometimes it doesn't.
In the code below, everything works as intended except the second two instances of image_index (spr_bird_raise and spr_bird_slash), which fail to load the corresponding sprite animations. Instead, the object returns to (and freezes in) frame 1 of its starting sprite animation.
To test whether there's any conflict, I've stripped out any other instructions to change the image index.
In the code below, everything works as intended except the second two instances of image_index (spr_bird_raise and spr_bird_slash), which fail to load the corresponding sprite animations. Instead, the object returns to (and freezes in) frame 1 of its starting sprite animation.
To test whether there's any conflict, I've stripped out any other instructions to change the image index.
Code:
//Dashes toward where you have clicked or touched//
if instance_number(obj_point) > 0 {
direction = point_direction(x,y,obj_point.x,obj_point.y);
//Covering the first two thirds of the distance//
if distance_to_object(obj_point) > (global.strikepower / 3) {
image_index = spr_bird_dash;
move_towards_point(obj_point.x,obj_point.y,accel);
accel += 1;
}
//The 'slow-down' phase of a long-range attack //
if distance_to_object(obj_point) < (global.strikepower / 3) and !collision_circle(obj_point.x,obj_point.y,50,obj_bird,true,false) {
image_index = spr_bird_raise;
room_speed = 30;
move_towards_point(obj_point.x,obj_point.y,5);
}
//Hits enemy if they collide at the 'attack' phase of dash//
if collision_circle(obj_point.x,obj_point.y,50,obj_bird,true,false) {
image_index = spr_bird_slash;
image_speed = 0.1;
room_speed = 60;
global.strikenow = 10;
move_towards_point(obj_point.x,obj_point.y,15);
}