• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Is the "animation end" event broken??

Cpaz

Member
In most cases. The animation end event is often skipped over for whatever reason. In the most basic of cases, it works as advertised. Is there some other non-documented condition to this event that I'm missing? I know that the animation event is triggered upon beginning the loop of a sprite, which sound pretty ineffective to be honest. Can anyone explain exactly how this event works if I am missing anything???
 
R

rui.rosario

Guest
I don't know for sure how it fails, since personally I either don't use it often or it always worked. But is it possible that you have an image_speed larger than 1 and that causes the Animation End event to fail to identify the end of the animation?

For example, you have 3 frames, you start at frame 2 and have an image_speed of 3. That would cause frame 2 to always be displayed, even though the animation was theoretically cycling.
 
F

Fuzenrad

Guest
Usually this happens when the image_speed is larger than 1, although it also happens in other cases, already noted too, i fix it not using image_single (default), try to redraw the sprite using draw_sprite (or draw_sprite_ext) and in the field to image_single, enter another variable and control the values in step event, also help the programming of characters that has many animations.
 
I

icuurd12b42

Guest
It works fine in 1757

But I had issues myself in the past. it was related to changing the sprite index

In any case it is not very reliable. I suggest you use your own animation. This is what I ended up doing in the past
image_speed = 0;
img_speed = 1;
img_index = 0;
step:
img_index+=img_speed;
if(img_index>=image_number-1)
{
//animation end event
}
img_index= img_index mod image_number;
image_index = img_index;
 
D

Dwojityv

Guest
I can confirm, that animation_end event sometimes doesnt trigger when image_speed > 1. Never noticed it when image_speed < 1 though.
 
J

joakimFF

Guest
the animation end event is only triggered if the image speed is set to land on the last frame, if you have 2 sub images and a image speed of 0.3 the animation_end wont trigger, this happens in 1.4.1757 as well.
I usually fix this by skipping image_speed all together and use my own img_spd var instead like.

create; img_spd = 0;

step: if img_spd < sprite_get_number(sprite_index) {
img_spd += 0.3;
}
else {
//trigger animation end stuff here
img_spd = 0;
}

draw: draw_sprite(sprite_index,img_spd,x,y);
 
I

icuurd12b42

Guest
the animation end event is only triggered if the image speed is set to land on the last frame, if you have 2 sub images and a image speed of 0.3 the animation_end wont trigger, this happens in 1.4.1757 as well.
I usually fix this by skipping image_speed all together and use my own img_spd var instead like.

create; img_spd = 0;

step: if img_spd < sprite_get_number(sprite_index) {
img_spd += 0.3;
}
else {
//trigger animation end stuff here
img_spd = 0;
}

draw: draw_sprite(sprite_index,img_spd,x,y);

You code lacks logic, no offense.

image speed variable used as a counter, hard coded actual speed... and calling get_number instead on image_number.

and not changing image_index may cause issues if your collision depends on the image_index...

I can confirm, that animation_end event sometimes doesnt trigger when image_speed > 1. Never noticed it when image_speed < 1 though.
I tried image_speed = 7 for a 4 image sprite and it worked fine. but I dont trust the event PERIOD. I been bitten too many times
 
J

joakimFF

Guest
You code lacks logic, no offense.

image speed variable used as a counter, hard coded actual speed... and calling get_number instead on image_number.

and not changing image_index may cause issues if your collision depends on the image_index...


I tried image_speed = 7 for a 4 image sprite and it worked fine. but I dont trust the event PERIOD. I been bitten too many times
Absolutely no offense taken :) I know your skill level is way above mine, I just shared a solution that has been working for me.
 
I don't personally use the Animation End event, because I like to keep most of my code in the create/step/draw events. Best way I've found to check for "animation end" is roughly:

Code:
animation_end = (image_index + image_speed < 0) or (image_index + image_speed > image_number);
... Works for positive or negative image_speed values.
 

Cpaz

Member
It works fine in 1757

But I had issues myself in the past. it was related to changing the sprite index

In any case it is not very reliable. I suggest you use your own animation. This is what I ended up doing in the past
image_speed = 0;
img_speed = 1;
img_index = 0;
step:
img_index+=img_speed;
if(img_index>=image_number-1)
{
//animation end event
}
img_index= img_index mod image_number;
image_index = img_index;
My problems recently stemmed when I had the aforementioned event do different things depending on what sprite is being played. Also in most cases, I throw everything in the animation event into the step event with something along the lines of "image_index>=image_number-1" as a check, and have little issue. (I normally have to tweak the statement once or twice due to my own incompetence.)
 
Top