Ooops
January 21, 2021, 05:19:11 AM

Author Topic: Best way to animate sprites/starting animation from a specific frame?  (Read 255 times)

Offline hosch

  • Jr. Member
  • **
  • Posts: 86
So I've been trying out the sprite animation options in AGK this morning.

I might be doing something wrong, but I found the PlaySprite() command not to be very flexible, especially when used with the loop parameter. I am programming a very small scope project: a 2D fishing arcade game. The fishing bobble has 4 frames (1,2 for idle and 3,4 for fish biting) and the game has two gamestates: waiting for a fish to bite and a fish has bitten.

While waiting, I am using
Code: [Select]
if GetSpritePlaying(spr_fishingBobble) = 0 then PlaySprite(spr_fishingBobble,2,0,1,2) in the WaitForFish() function. When a fish has bitten, I switch to the FishBitten() function and use
Code: [Select]
if GetSpritePlaying(spr_fishingBobble) = 0 then PlaySprite(spr_fishingBobble,2,0,3,4)
Isn't there a better way, where I set up the sprite animation with the loop parameter and switch to a different frame / frame range for example? Because when I set it up this way: PlaySprite(2,1,1,2) in one function and then call PlaySprite(2,1,3,4) in the other, it doesn't work (and it shouldn't, because it's only supposed to be called once with the loop parameter, if I understand correctly). I've also tried StopSprite() then SetSpriteFrame(3) and PlaySprite(2,1,3,4). It didn't quite work either.

What do you guys find is the best way to handle sprite animation with a specific frame range? Thanks for your answers!

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal