I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: PlasmaKaboom on April 21, 2017, 09:51:55 PM

Title: Can I make a sprite pause?
Post by: PlasmaKaboom on April 21, 2017, 09:51:55 PM
Is it possible to make a sprite freeze in place in the middle of it's animation?
Title: Re: Can I make a sprite pause?
Post by: PiranhaTooth on April 22, 2017, 12:44:39 AM
The way in which to do this is to set the image_speed variable to equal 0. This means it's going to cycle through 0 images every frame/step. If you wanted to do this in the middle of an animation, say at a specific frame of the animation, for example frame 14, you'd do something like

Code: [Select]
if(image_index = 14)
{
    image_speed = 0;   
}

For an example like this, every time the sprite finds itself on the 14th image of it's animation, it will stop cycling through the images of the animation, because the speed of which it cycles though the animation is set to 0. You could implement a Boolean (true/false) variable in the creation code called imageFreeze or something, and have it so that has to be set to true as well as the image_index being 14. This way while you don't want it to freeze (in this case having imageFreeze being false), it's still able to cycle through its animation normally.