game-maker-studio-1.4

How To Change Sprites After A Separate Sprite Ends?


I have two separate objects - one of a character and one with a text scrolling animation. The text sprite object has the Animation End event and a code where the last frame stops leaving the entire text showing. During the game the character object is animated sprite of his mouth moving, and a separate sprite without his mouth moving. I wanted to make it to when the text object's animation ends the player object's talking animation changes to the sprite of his mouth not moving. Sorry if this sounds confusing, but it's kinda similar to those RPG games where if the text stops scrolling the player sprite stops talking.

Is there any code to this, or is it really possible to do?


Solution

  • in the animation end event of the text object, you have to add a line of code that changes the character's sprite. Assuming your character instance is designated as "character" (Inside the scope of the text object), and the sprite name is "spr_character_static", the code would look like this :

    In the text animation end event :

    character.image_index = spr_character_static;
    

    Hope this helps !