Freezing a Animation of a Sprite

My object's sprite animates when you hover over it with your mouse, and reverts to the first frame when you leave the collision box, however I am trying to get the animation to stop on the last frame while the mouse is still inside the collision box instead of looping over and over again. I have been stuck trying to figure it out.
 

Spam1985

Member
image_speed = 0

Does that do it? (That's if you want it to stop on the frame it's at when you move the mouse).
 

Spam1985

Member
I mean... unless I'm crazy (which is always a possibility) that should work...

We are literally stopping the animation there when it hits the last frame.

Need to see some code I think!
 

Spam1985

Member
Well now I can see the problem! Couple of things:

What is this?
GML:
//image_index = 0-9; what is this? Get rid of it!
GML:
///Create Event

image_speed = 0;
image_index = 0;
mouse_over = false; //is the mouse over us?
GML:
///Mouse Enter Event
mouse_over = true;
GML:
///Mouse Leave Event

image_speed = 0;
image_index = 0;
mouse_over = false;
GML:
///Step Event
if mouse_over = true then
{

    if image_index >= image_number then

    {

        image_speed = 0;

    }
    else
    {
        image_speed = 1;
    }
}
I'm getting tired and making tons of mistakes.... sorry!
 
Last edited:
Well now I can see the problem! Couple of things:

What is this?
GML:
//image_index = 0-9; what is this? Get rid of it!
The Mouse Enter Event only fires when the mouse first hits the object I believe, so we should be putting this in the Step Event:
GML:
///we need to check the mouse is over our position... I got the code wrong here, sorry... trying to fix it
{
    if image_index = image_number then
    {
    image_speed = 0;
    }
}
THANK YOU VERY MUCH!!!! I think I neglect the step event, because I'm still unsure what the term "step" means. But I can't thank you enough :D
 

Spam1985

Member
I am getting tired and making loads of errors... does that work? If not, I updated my message and added a load more stuff. My brain just isn't working.
 
THANK YOU VERY MUCH!!!! I think I neglect the step event, because I'm still unsure what the term "step" means. But I can't thank you enough :D
Step Event is an event that is run every frame. So generally 60 times a second. There are a few other events that are run like this, mainly the Draw Events and Collision Events (as well as a few other miscellaneous ones).
 
Top