Changing the sprite but keeping the image_index for the new sprite

Zuljaras

Member
I have the following scenario.

I have arrack animation while on the ground and attack animation while in the air.

I want to be able to change my sprite from the air one to the ground one but keep the animation where it left off.

While I am in the air I have the sprite index to change from player_attack_air to player_fall while there is no solid ground beneath the player.
However if there is solid ground beneath the player and he is still in his air_attack animation I want him to change to his ground attack animation but start from the last image_index he was in the air attack sprite.

I have the following code for the moment:
Code:
if sprite_index == playersattackright_air
    {
        im = image_index;
    }

if sprite_index==playersattackright_air && !place_free(x,y+vspeed) && sprite_index != playersattackright
    {   
        sprite_index = playersattackright;
        image_index = im;
        image_speed = 0.3;
    }
 

TsukaYuriko

☄️
Forum Staff
Moderator
What is the problem you're facing with this?
What behavior are you expecting?
What happens instead?
 

Zuljaras

Member
What is the problem you're facing with this?
What behavior are you expecting?
What happens instead?
I just saw that I am placing this in the step event instead of the end_step event.

The problem was that the synch of both sprites was not ok.
the new one was playing from image_index 0. Not from "im".
 
Top