0

I have 4 (0-3 animation frames) different images of a coin animation with differet states of it spinning. I would like to make it look like its spinning by adding another 2 frames (4-5) to make it look like it spins. In current situation it looks like the coin spins 180 degrees and goes back to it's original position. I would like to flip vertically ONLY the 4th and 5th frame. How can i achieve that without making new redundant pngs?

I know making 2 new pngs is not a big deal in this case, but if i had more frames, and/or bigger sprites it could make a significant difference in future projects.

My current animation frames

Community
  • 1
  • 1
Eternal
  • 303
  • 1
  • 2
  • 16

4 Answers4

2

this is one way to accomplish the task.

Inside the ready function of godot write

#used to store frame value
var frame = 0

Inside the function that your using that runs every frame write:

frame += 1

#resets the value representing the current frame
if frame > 5:
    frame = 0

if frame == 4 || frame == 5:
    #this should be whatever function you use to flip the sprite vetically
    flip_h = true 
else:
    #this should be whatever function you se to flip the sprite horizontally
    flip_h = false
Noah Lewis
  • 85
  • 1
  • 8
1

I was thinking you could make the animation flip horizontally when it reaches the last fame, however that would mean you would have to omit #4 and #5 to avoid duplicates, but it still would look odd because frame #3 would skip directly back to frame #0. I tried thinking of different orders the sprite frames could be placed in to clean this up, but all my solutions either result in duplicate frames, or ugly skips. Maybe you might be able to solve what I couldn't.

Unfortunately, it seems that though Godot supports play_backwards functionality for the animation_player node, there is no such feature when it comes to animated_sprite. Too bad, because this would likely solve your problem.

For now, I think your best bet is to do what you were trying to avoid.. flip the sprite images yourself and add them as animation frames, or make a separate animation containing the flipped sprites and have them switch back and forth after their last frames, respectively. It might be a lot of work for super large projects, but without some kind of play_backwards functionality for animated sprites, I don't think it's worth breaking your back trying to find a workaround this time.

Of course, if I am wrong, I would welcome any correction from the community.

Good luck.

Christopher Bennett
  • 803
  • 1
  • 8
  • 20
0

You probably already know this because I recognize the udemy course this screenshot is from, as I am doing it right now, and this is explained later in the course (when adding spikeman enemy). But for those who don't know it can be solved by adding an AnimationPlayer and adding new animation track that deals with animation flip_h property of AnimatedSprite. Then you have to set flip_h on those last 2 duplicated frames.

Celebes
  • 1,371
  • 1
  • 12
  • 21
0

You could use the signals to detect when the animation has finished

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 03 '22 at 17:06