New Maker

Discussion in 'Programming' started by Ezlol, Jun 17, 2019.

  1. Ezlol

    Ezlol Member

    Joined:
    Jun 17, 2019
    Posts:
    5
    Hello! I'm Ezlol as my username says (no duh) and I am relatively new to GM2, I'm busy trying to make a looking up animation, and a looking down animation using DnD (too lazy to use code lol) and I can't seem to find any sprite-related blocks for this, causing the animation to loop even when I set the loop to play once-
     
  2. Fat_Man3468800

    Fat_Man3468800 Member

    Joined:
    Jun 22, 2016
    Posts:
    487
    Set the variable (I'm pretty sure there's a set variable DnD block) image_speed to 0, that will freeze the animation in game. I assume you set the loop once in the sprite editor, that only applies to the preview. Then set the variable image_index to the appropriate index in your sprite (remember computers start counting from 0) to set the animation to the one you want.

    Hope I helped :)
     
  3. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,889
  4. Ezlol

    Ezlol Member

    Joined:
    Jun 17, 2019
    Posts:
    5
    This was somewhat helpful, but I am unsure as to why it is still not working, I have it set up as such;

    Set Sprite
    [PlayerUp_sprite]
    [Frame: 0] relative; no
    |
    Assign Variable
    [Image_speed]
    [Value: 0] relative; no
    |
    Assign Variable
    [Image_index]
    [Value: 10] relative; no

    Is this correct?
     
  5. Fat_Man3468800

    Fat_Man3468800 Member

    Joined:
    Jun 22, 2016
    Posts:
    487
    You have to set the variable image_speed to 0 at the create event of the player, otherwise it will keep looping (by default its value is 1). Also, I assumed your "animation" is 3 images in 1 sprite, looking up, idle, and down. If that's not the case, and it is 3 actual animations in 1 sprite, then the code blocks needed are going to be a lot more complex. Considering you're just getting familiar with the system, I'd suggest splitting the animations into 3 sprites and work with sprite_index instead. Image index of 10 sounds like it's 3 animations in 1 sprite.

    Create Event:
    - Set variable image_speed to 0
    - Set variable image_index to idle player image index

    Step Event:
    - If condition to look up
    - Set variable image_index to player looking up image index
    - Else
    - If condition to look down
    - Set variable image_index to player looking down image index

    - Else
    - Set variable image_index to idle player image index

    Hope I helped :)
     
  6. Ezlol

    Ezlol Member

    Joined:
    Jun 17, 2019
    Posts:
    5
    Again, slightly useful, I figured out how to make the animation freeze, yet I can't get it to play the animation, and freeze on the final frame of the looking up sprite (I have all three animations split between 3 sprites)
     
  7. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,680
    Instead of always setting image_speed to 0, you might wanna set it to 0 in the Animation End event instead... this event occurs when the current sprite rolls over from the last to the first image of its animation. (Since this happens after the rollover, you also need to set image_index to image_number - 1, which selects the last image - sprite images are zero-indexed, so they go from 0 ~ image_number-1 instead of 1 ~ image_number)
     
  8. Ezlol

    Ezlol Member

    Joined:
    Jun 17, 2019
    Posts:
    5
    could you or someone else possibly send an image of how the code blocks are supposed to look due to me being dumb enough to not understand what I'm supposed to do, I have looked for YT tutorials and such and I still don't understand how to make a sprite finish, the looking up sprite is 5 frames, and I have it set to when I let go of up, it goes back to the idle animation
     
  9. woods

    woods Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    @Ez ..do you mean something like this?

    event keyboard press (W or up arrow or whatever)
    control tab>start block
    change sprite (sprite_index = spr_player_up or whatever your looking up sprite is called )
    control tab>end block
     
  10. Ezlol

    Ezlol Member

    Joined:
    Jun 17, 2019
    Posts:
    5
    sorry if in later replys I seem pissed off- this is making me upset I can't understand it, also the image was unable to be seen so that doesn't help- but wdym 'start block' and 'end block'?
     
  11. woods

    woods Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    i totally get it bro.. its frustrating when i dont understand something... no worries.. just take a breath and relax.. we all learn at our own pace... and sometimes(most of the times i need to have things beat into my head before they stick)


    you were asking for the drag n drop equivalent to code... the start and end blocks are the little triangle thing in dragh and drop that mean { and } in code..

    Code:
    if keyboard_check(ord("W"))   // in DnD this is the event keypress
    {                                               // in DnD this is start block
    sprite_index = spr_up              // in DnD this is change sprite
    }                                                // in DnD this is end block
    
     
  12. pipebkOT

    pipebkOT Member

    Joined:
    Dec 13, 2018
    Posts:
    210
    @Ezlol

    it depends what's the purpouse of the animation, if is not and idle animation, you can use the "animation end" event

    this event is called when the animation has ended.

    in it put:

    image_speed=0



    so the animation doesn't loop
     

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