Sprite Animation just 1 time and not a loop

Discussion in 'Programming' started by Coleft, Oct 3, 2016.

  1. Coleft

    Coleft Guest

    How can I do that coz if I add the Sprite to an object, it will start again and again
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    Set image_index to image_number - 1 and set image_speed to 0 in the animation end event.
     
  3. Coleft

    Coleft Guest

    Can you tell me which events I have to add in and which code I have to write, I'm new sorry
     
  4. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,551
    Add Event--->Other (the icon is a small green rhombus)--->Animation End

    Tip: this event is great for explosions and other effects (make them destroy themselves in the animation end event).
     
  5. Chreech Okash

    Chreech Okash Member

    Joined:
    Sep 29, 2016
    Posts:
    48
    What you want to do after the animation ends?

    If you want to destroy the object-

    Under Animation End-
    Execute a piece of code-
    Then write-
    instance_destroy()

    if you want to stop the animation at a particular frame-

    Under Animation End-
    Execute a piece of code-
    Then write-
    image_speed=0
    image_index= "Any number of frame from the animation like 0,1,2,3 etc."
     
  6. Bryan Green

    Bryan Green Guest

    But how do you target WHICH animation has ended? if you have an idle animation that gets switched to another animation you want to run once-- if you used 'animation end' it'll fire on every cycle of the idle animation, not just the other animation....
     
  7. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    You can check the value of the variable sprite_index in the animation end event.
     
  8. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,551
    Or in more practical terms, something like this:
    Code:
    ///Animation end event
    switch(sprite_index){
      case spr_attackanimation1:
      case spr_attackanimation2:
      case spr_someotheranimationthatonlyrunsonce:
        sprite_index = spr_idle
      break
    
      default: // do nothing
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice