Klanes
Member
Hello everyone. First of all I have to say that my English is not very good and that I am a real code noob.
Well, I am using an 8 position motion setup based on this code:
On the other hand I have 4 sprites for the "idle" and 4 sprites for "move":
Everything seems to be fine but when moving diagonally lower left use the sprite "spr_player_move2" (moving left), which is ok, but when moving diagonally lower right use the sprite spr_player_move3 "(moving right), which not what I want. I would like you to use the "spr_player_move0". The same goes for diagonal movements up. Here is the problem:
In summary, one of the move diagonals makes them with the correct sprite (running sideways) and the other does not (running front and from behind).
Help please! Thanks in advice!
Well, I am using an 8 position motion setup based on this code:
GML:
//movement
hsp = (keyboard_check(ord("D")) || keyboard_check(vk_right)) - (keyboard_check(ord("A")) || keyboard_check(vk_left));
vsp = (keyboard_check(ord("S")) || keyboard_check(vk_down)) - (keyboard_check(ord("W")) || keyboard_check(vk_up));
hsp *= move_speed;
vsp *= move_speed;
//moving
var moving = hsp!=0 || vsp!=0;
//states
switch(state){
case "idle":
//change to move
if (moving) state = "move";
break;
case "move":
//change to idle
if (!moving) state = "idle";
break;
}
//direction
if (moving){
var _dir = point_direction(0, 0, hsp, vsp);
dir = floor(_dir/90);
}
//sprites
sprite_index = asset_get_index("spr_player_" + state + string(dir));
//movement
x += hsp;
y += vsp;
Everything seems to be fine but when moving diagonally lower left use the sprite "spr_player_move2" (moving left), which is ok, but when moving diagonally lower right use the sprite spr_player_move3 "(moving right), which not what I want. I would like you to use the "spr_player_move0". The same goes for diagonal movements up. Here is the problem:
In summary, one of the move diagonals makes them with the correct sprite (running sideways) and the other does not (running front and from behind).
Help please! Thanks in advice!