How to change an sprite direction on a path?

M

MercuryRich123

Guest
How would I change tupload_2016-11-20_18-54-47.pnghe direction of the enemy on the path, the enemy has separate sprites for turning. Also I have tried switch statements for this but to no avail. Oh, and `image_angle = direction`. Thanks for any help. :D [EDIT] And don't laugh because I have windows 8.1 :( [/EDIT]
 

TheouAegis

Member
If your movement is 8-directions...

End Step Event:
First option:
Code:
var dir = point_direction(0,0,sign(x-xprevious>>2), sign(y-yprevious>>2));
/* assign the sprite based on dir however you want; dir will be 0, 45, 90, 135, and so on */
/* change the >>2's to change the delay between direction changes */
Second option:
Code:
var d = sign(x-xprevious) + sign(y-yprevious)*3;
switch d {
case 0:  /* no change */
        break;
case -1: /* moving left */
        break;
case -2: /* moving up and right */
        break;
case -3: /* moving up */
        break;
case -4: /* moving up and left */
        break;
case 1: /* moving right */
        break;
case 2: /* moving left and down */
        break;
case 3: / moving down */
        break;
case 4: /* moving down and right */
        break;
}
 
Top