Hello Guest

Author Topic: Animation Frame Rate  (Read 5242 times)

marcosramos

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Animation Frame Rate
« on: November 27, 2012, 10:43:06 pm »
I just upgraded a really old tk2d project, and now (with some of your help) it is fully compatible except for a bug that wasn't happening before the upgrade. I could speed the velocity of the game up so everything would run faster, all the animation would run faster as well, but now it's not working anymore. I can see the framerate in the collection is changing but it's not affecting the animated elements using that clip in scene.

what i did way back then was:

int currentClipId = animSprite.clipId;
animSprite.anim.clips[currentClipId].fps = GlobalInitialFpsController * GlobalGameVelocity; 
           

then it changed to:
animSprite.CurrentClip.fps = GlobalInitialFpsController * GlobalGameVelocity;


The initialFps was to keep the reference of the fps, because since the fps was being changed at the collection it got lost when the game stopped.  I've read in other topics that you wanted to change this so that the collection wouldn't change the fps, just the instances would be affected. Well, i couldn't find if this was done, now i'm kindda at a loss in how to make it work.


Thanks in Advance!

marcosramos

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Animation Frame Rate
« Reply #1 on: November 27, 2012, 10:48:40 pm »
Well i saw in another post one of your suggestion and i made a workaround. On the tk2dAnimatedSprite i changed:

clipTime += Time.deltaTime *fps;

to

clipTime += Time.deltaTime * (GlobalGameVelocity  * GlobalInitialFpsController);

It worked, but i'm not sure if i should keep it like this.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Animation Frame Rate
« Reply #2 on: November 27, 2012, 10:59:13 pm »
Doesn't that just change fps to be a global value? It's fine if thats what you want, but now there are overloads which let you change fps on an instance, eg. this
http://unikronsoftware.com/2dtoolkit/doc/html/classtk2d_animated_sprite.html#adae648a4d3f19ac8ff1702b292dfdadd

You could set it up so you call this variant instead, if you'd like to keep the tk2d codebase unchagned.

marcosramos

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Animation Frame Rate
« Reply #3 on: November 29, 2012, 10:25:41 pm »
Understood. I will keep the tk2d unchanged then, and use the overrideFps.

Thanks.