Mononoke011
Member
Hi everyone,
This is another bit of code I haven't been able to work out on my own, despite finding similar posts; I am a beginner! I am making a platformer where I am using left and right facing sprites for idle, running, jumping, etc. The code I am using for changing animation was acquired through a Shaun Spalding tutorial, though instead of using left and right facing sprites, he just flipped the right facing sprite.
My previous attempts only managed to have the running sprite change when the player's hsp was -hsp, but I couldn't work out what to code for the idle and jumping sprites.
When the player is moving left, I would like sPlayerA to change to sPlayerALeft; sPlayer to sPlayerLeft; sPlayerR to sPlayerRLeft.
Below is the current sprite changing/animation coding used:
------------------------------------------------------------------------------------------------------
//Normal Animation - changing sprite, graphics, etc
if (!place_meeting(x, y + 1, oWall))
{
//jumping
sprite_index = sPlayerA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
canjump = 8;
image_speed = 1;
if (hsp == 0)
{
//idle
sprite_index = sPlayer;
else
{
//Running
sprite_index = sPlayerR;
if (key_fast)
walksp = 4 else walksp = 2.5
}
}
------------------------------------------------------------------------------------------------------
Thanks everyone for your help!
//Edit// I'm not wanting to flip as my left and right facing sprites are slightly different
This is another bit of code I haven't been able to work out on my own, despite finding similar posts; I am a beginner! I am making a platformer where I am using left and right facing sprites for idle, running, jumping, etc. The code I am using for changing animation was acquired through a Shaun Spalding tutorial, though instead of using left and right facing sprites, he just flipped the right facing sprite.
My previous attempts only managed to have the running sprite change when the player's hsp was -hsp, but I couldn't work out what to code for the idle and jumping sprites.
When the player is moving left, I would like sPlayerA to change to sPlayerALeft; sPlayer to sPlayerLeft; sPlayerR to sPlayerRLeft.
Below is the current sprite changing/animation coding used:
------------------------------------------------------------------------------------------------------
//Normal Animation - changing sprite, graphics, etc
if (!place_meeting(x, y + 1, oWall))
{
//jumping
sprite_index = sPlayerA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
canjump = 8;
image_speed = 1;
if (hsp == 0)
{
//idle
sprite_index = sPlayer;
else
{
//Running
sprite_index = sPlayerR;
if (key_fast)
walksp = 4 else walksp = 2.5
}
}
------------------------------------------------------------------------------------------------------
Thanks everyone for your help!
//Edit// I'm not wanting to flip as my left and right facing sprites are slightly different
Last edited: