Scrolling Game Development Kit Forum

SGDK Version 2 => General Discussion => Topic started by: Tanja on 2008-01-26, 11:48:20 AM

Title: name your frame! / sprite animation preview
Post by: Tanja on 2008-01-26, 11:48:20 AM
once again i come up with a new suggestion. i do a lot with sprite animations, and since there is no preview window, i have to type in some repeat count and look at the animation ingame. i change the overall repeat sometimes very often until it looks smooth. and every time i have again to calculate the overall frame count and change the rule. now imagine i could "name" the last frame. in my rule i would no more say "if frame == 349" but "if frame == myLastFrame". i could change the animation without ever looking and calculating frames again. and it would be a very good method to name other frames in the middle of the animations for other purposes.

i don't know how much work this would be. how about this variation: one can mark up to x frames with x predefined labels.
and having a sprite animation preview window, like the tileset editor has, would also be cool.

what do you think?
Title: Re: name your frame! / sprite animation preview
Post by: durnurd on 2008-01-26, 04:19:37 PM
There is a sprite preview window.  The last button above the sprite state list, to the right of the Down Arrow, that looks like a fire in an animation cell.  You can press that to open up a preview window of the current state and when you change the animation that window will automatically update if you don't close it.
Title: Re: name your frame! / sprite animation preview
Post by: Tanja on 2008-01-26, 04:26:45 PM
i must have been beaten with blindness. what about the other suggestion?
Title: Re: name your frame! / sprite animation preview
Post by: durnurd on 2008-01-26, 04:43:34 PM
It would be easy, I think, to add a few lines in SpriteState.cs such that you could get the length of the animation easily without modifying the IDE if you only need to get the total length.

For example (just before the last '}'):
Code: (SpriteState.cs) [Select]
   public int AnimationLength
   {
      get
      {
         return m_frames.Length;
      }
   }
Then create a rule like:
Rule Type: If
Rule: ==
Left operand: frame
Right operand: CurrentState.AnimationLength
Title: Re: name your frame! / sprite animation preview
Post by: Tanja on 2008-01-27, 05:13:54 AM
error:
SpriteBase.cs(2436,17) : error CS0246: The type or namespace name 'm_frames' could not be found
Title: Re: name your frame! / sprite animation preview
Post by: bluemonkmn on 2008-01-27, 08:26:42 AM
Are you sure you put the code in SpriteState and not SpriteBase?
Title: Re: name your frame! / sprite animation preview
Post by: Tanja on 2008-01-27, 08:37:13 AM
oops. i'm sorry. but this shows only the frames without considering the repeat count. my animation has 20 frames, but with repeat count it is 133 frames long.
Title: Re: name your frame! / sprite animation preview
Post by: bluemonkmn on 2008-01-27, 08:45:12 AM
Instead of m_frames.Length, try:
m_frames[m_frames.Length - 1].m_nAccumulatedDuration
or
m_frameIndexMap.Length

m_frameIndexMap is used to map frame counter numbers to which frame is displayed based on the repeat count of all the previous frames.  So if you have 2 frames, and the first frame has a repeat count of 10 and the second has a repeat count of 20, then m_frameIndexMap should have 30 elements with the first 10 values being 0 and the last 20 values being 1.
Title: Re: name your frame! / sprite animation preview
Post by: Tanja on 2008-01-27, 09:00:52 AM
m_frameIndexMap.Length works perfectly! thank you
Title: Re: name your frame! / sprite animation preview
Post by: durnurd on 2008-01-27, 09:06:07 AM
oops. i'm sorry. but this shows only the frames without considering the repeat count. my animation has 20 frames, but with repeat count it is 133 frames long.

Oh, yeah.  Oops.  I generally don't have the ability or time to test code I write here before I have to go somewhere else or get sidetracked :)