How to Make Objects Sprite Change as it follows



I am making a boss enemy in a platformer, where the enemy shoots off rockets and they follow the player. I want the sprite of the rocket to change depending on the direction it is going, but I have no clue how to. I tried this:

if vspeed > 0 while hspeed < 0
{sprite_index = Spr_RocketDownLeft}
if vspeed > 0 while hspeed > 0
{sprite_index = Spr_RocketDownRight}
if vspeed < 0 while hspeed < 0
{sprite_index = Spr_RocketUpLeft}
if vspeed < 0 while hspeed > 0
{sprite_index = Spr_RocketUpRight}

But the sprite doesn't change and if it does it stays like that forever. How can I make it change based upon the direction it is going?
the while() function is a loop, whereas the if() statement is a conditional/truth check. They won't work together the way you have them as you have written above.

Please check the manual for those two functions to read more about them.

In the meantime, what you can do is just have the one sprite Spr_RocketRight for example, and to set the angle of the rocket, just use:

image_angle = direction

As it looks like you are not using the built in variables, you may need to do something like this instead:

var my_dir = point_direction(0, 0, hspeed, vspeed)
image_angle = my_dir