I Wanna Community

Can I make a sprite pause?

0 Members and 1 Guest are viewing this topic.

Offline PlasmaKaboom

  • 15
  • OS:
  • Unknown Unknown
  • Browser:
  • Chrome 57.0.2987.146 Chrome 57.0.2987.146
  • Playstyle: Keyboard
Can I make a sprite pause?
« 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?

Offline PiranhaTooth

  • 38
  • I'm a totally mediocre fangame player...
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 57.0.2987.133 Chrome 57.0.2987.133
    • Steam Profile
  • Playstyle: Keyboard
Re: Can I make a sprite pause?
« Reply #1 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.
Meme connoisseur of many Twitch chats...