Okay, first thing's first... PLEASE try to post any code using the
[CODE=gml][/CODE]
tags rather than screenshots! Makes editing and reading a lot easier for everyone... The second thing is to say that I would suggest "compartmentalising" things. By this, what I mean is break everything down into sections and work on each section as an individual unit. For example, at the moment, you have it so that the player moves instantly when the key is pressed... This is not normally the best idea! What you should do is get the player input and store that in variables, then deal with the movement in a separate section. This will make things (like changing sprite) a lot easier going forward. So:
GML:
// CREATE EVENT
spd = 2; //This controls the speed of movement
// STEP EVENT
var _hspd = 0; // temp vars to store horizontal and vertical speed
var _vspd = 0;
// Deal with input first
if keyboard_check(vk_left) _hspd = -1;
if keyboard_check(vk_right) _hspd = 1;
if keyboard_check(vk_up) _vspd = -1;
if keyboard_check(vk_down) _vspd = 1;
// Now deal with movement
if _hspd != 0
{
x += spd * _hspd;
}
if _vspd != 0
{
y += spd * _vspd;
}
Now that you've separated these things out you can add in a further section to deal with the sprite (again, a separate section for dealing with the sprites and animations):
GML:
// STEP EVENT, after everything else
// Deal with animation
if _vspd != 0 || _hspd != 0
{
sprite_index = spr_Player_Running;
}
else sprite_index = spr_Player_Idle;
By splitting your code up like this into logical "blocks" or "compartments", you are making it easier to visualise what is actually happening, and also making it a LOT easier to change and edit things as you go along.
Hope that helps!