I want to make my object move (x += 3) once when i press the right key down and only move that direction again once the key has been released and then pressed again. At the moment it moves a few times as it reads me pressing down the right key.
I have 4 different objects - one is character standing still facing right (oStillR), one is character step right (oMoveR), one is character standing still facing left (oStillL), the last is character step left (oMoveR). The character is a slug.
I want to press a direction from the standing still position and have it change to the respective step object and then back again from that object when you press the same direction again.
I hope this makes sense and i'm sure people will be able to easily see my errors! At the moment very little of what i wish to work is working...
Here's the code for my objects:
oMoveL - step event:
if (keyboard_check(vk_right))
{
x += 3;
instance_destroy()
instance_create(x, y, oStillR)
}
if (keyboard_check(vk_left))
{
x -= 3;
instance_destroy()
instance_create(x, y, oStillL)
}
oStillL - step event:
if(keyboard_check(vk_right))
{
x += 3;
instance_destroy()
instance_create(x,y, oStillR)
}
if (keyboard_check(vk_left))
{
x -= 3;
instance_destroy()
instance_create(x,y, oMoveL)
}
oStillR - step event:
if (keyboard_check(vk_right))
{
x += 3;
instance_destroy()
instance_create(x, y, oMoveR)
}
if (keyboard_check(vk_left))
{
x -= 3;
instance_destroy()
instance_create(x, y, oStillL)
}
oMoveR - step event:
if (keyboard_check(vk_right))
{
x += 3;
instance_destroy()
instance_create(x, y, oStillR)
}
if (keyboard_check(vk_left))
{
x -= 3;
instance_destroy()
instance_create(x, y, oStillL)
}
Thanks!