New Maker

E

Ezlol

Guest
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-
 
D

DarthTenebris

Guest
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 :)
 
E

Ezlol

Guest
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 :)
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?
 
D

DarthTenebris

Guest
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?
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 :)
 
E

Ezlol

Guest
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 :)
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)
 

Yal

šŸ§ *penguin noises*
GMC Elder
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)
 
E

Ezlol

Guest
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)
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
 

woods

Member
@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
 
E

Ezlol

Guest
@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
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'?
 

woods

Member
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
 

pipebkOT

Member
@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
 
Top