Don't know how to deal with sprite animation :(((

Reddoka

Member
I want my animation doesn't loop so I can add the transition after it, but here's everything I can thing about, and of course, it doesn't work
GML:
if skeleton_animation_get_frames(sprite22) = 10
{
    image_speed = 0;
    Slidetrans(TRANS_MODE.GOTO, room3);
}
else
{   
    image_speed = 1
}
I'm kinda new to this so can someone help me please? OwO
 

kburkhart84

Firehammer Games
1. Are you using skeletal animation? Or are you just using a frame based sprite? If it is not skeletal, you are using the wrong function to try to figure out the status of the animation.

2. sprite22 sounds like the name of a sprite resource. If that is correct, then you are still barking up the wrong tree. The amount of frames the sprite has will have nothing to do with what frame it is currently on in your object.

3. I don't know what Slidetrans() is.

4. Once you have set the image_speed to 1 once(typically when the animation starts), you don't have to do it again. So even once you fix the issues about detecting when the animation is finished, you won't need the else{image_speed = 1} part, because image_speed will be 1 from before anyway, so it is a slight waste of code and time. It doesn't affect much at this scale, but you should get used to the idea of avoiding code that isn't needed, as later on the performance issues would be much larger.

Now, about your issue, if you are using regular frame based animations, you figure things out in different ways. You can use the animation end event, which will execute once the sprite is done with that animation. The catch there is simply that you will want to verify which animation it is(or store the state in a variable) so you can do your transition only if it is coming from the right point. An alternative if you want to actually check within the step event, you can use the image_index variable to check. It increases frame by frame, so you can see once it is past the frame you care about, you then go into the transition.
 

Reddoka

Member
Thanks very much! I'm still figuring it. Can you give me an example of the animation end event please???
 

kburkhart84

Firehammer Games
It is just another event. I think you need to find yourself a tutorial...start with the basics. A platformer is far from basic, but there are plenty of tutorials out there on them. They explain how to do the kind of thing you are doing, changing the state of your object at different times, changing the sprite animation accordingly, and some use the animation end event. The manual is also a good place to go. I feel like you haven't really done much tutorial following just yet, mainly because you are trying to combine skeletal animation with sprite animation and don't know the difference.
 
Top