C
ChrisEXEL
Guest
I've been trying for a while and I can't figure out a way to "animate" a sword swing attack. What I want is for the sword to swing down really fast and then return to its previous state every time the left mouse button is pressed. I want this to be able to happen at any angle the sword is at and have it swing for the same amount every time. Sword movement example
This is the code I used to set up the default movement of the sword around the player
Create event
Step event
This is how I imagine it should look
This is the code I used to set up the default movement of the sword around the player
Create event
GML:
dis = 11; // Distance from the player to the cursor
GML:
dir = point_direction(obj_Player.x, obj_Player.y, mouse_x, mouse_y); // Cursor pointing at mouse coords
// Clamp the direction (if you want the cursor to rotate only within a specific range).
//dir = clamp(dir, 0, 180);
// Calculate x and y coords for the cursor
x = obj_Player.x + lengthdir_x(dis, dir);
y = obj_Player.y + lengthdir_y(dis, dir);
// Rotate the cursor sprite
image_angle = dir;
///change player sprite
if obj_Player.x < mouse_x
{
image_xscale = 1;
image_yscale = 1;
}
else
{
//image_xscale = -1;
image_yscale = -1;
}