TammyLizzyLuu
Member
I have a player sprite that's different depending on the side it's viewed from and I've been trying for 5 hours or so to get the idle left animation to stay in place after turning left.
Here is my step event's code. I'm doing this on mobile so I can't attach the file; obviously I got pretty fed up with sitting at my desk.
//Get Player Input
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
var idle = keyboard_check(vk_nokey);
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,oWall)) and (key_jump)
{
vsp = -8;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Walk & Jump Animation
if (!place_meeting(x,y+1,oWall))
{
sprite_index = sPlayerAlt;
image_speed = 1;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
if (hsp == 0)
{
sprite_index = sPlayer;
}
else
{
if (sprite_index!=sPlayerWR) sprite_index = sPlayerWR;
}
if (hsp < 0)
{
sprite_index = sPlayerWL;
}
}
Yes, I have been watching a bit of Shaun Spalding.
Any one have any ideas how I could adapt this to allow for my idle left animation to apply? If you think attaching the file would make it easier then I'll do so.
Here is my step event's code. I'm doing this on mobile so I can't attach the file; obviously I got pretty fed up with sitting at my desk.
//Get Player Input
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
var idle = keyboard_check(vk_nokey);
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,oWall)) and (key_jump)
{
vsp = -8;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Walk & Jump Animation
if (!place_meeting(x,y+1,oWall))
{
sprite_index = sPlayerAlt;
image_speed = 1;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
if (hsp == 0)
{
sprite_index = sPlayer;
}
else
{
if (sprite_index!=sPlayerWR) sprite_index = sPlayerWR;
}
if (hsp < 0)
{
sprite_index = sPlayerWL;
}
}
Yes, I have been watching a bit of Shaun Spalding.
Any one have any ideas how I could adapt this to allow for my idle left animation to apply? If you think attaching the file would make it easier then I'll do so.