I think I know what's the problem.
image_index updates by image_speed each frame and so
@FrostyCat suggested code will fire each frame. So if you need on each sprite image_index change do this:
Code:
if (image_index_previous != floor(image_index)) {
/* Perform actions here */
image_index_previous =floor(image_index);
}
This would indeed do the trick. If you DO need to do anything with the areas 'between' frames, here's some info:
Frames are actually decimals.
Let's say we have a sprite with 4 frames.
If your image speed is 1.5, and you're on frame 0, this is what happens:
Image index 1.4 is considered (by the engine) to be image index 1. It will show the first frame.
However, image index 1.5 is rounded up to 2, and will thus show the 2nd frame.
The reason using 'floor' works here, is it rounds the numbers down, so that we're not working with decimals.
Otherwise that code would trigger every frame (1, 1.1, 1.2, etc).
That code above will only trigger whenever the frame changes by a whole number (1, 2, 3, etc).