Author Topic: name your frame! / sprite animation preview  (Read 4867 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
name your frame! / sprite animation preview
« 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?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: name your frame! / sprite animation preview
« Reply #1 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.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: name your frame! / sprite animation preview
« Reply #2 on: 2008-01-26, 04:26:45 PM »
i must have been beaten with blindness. what about the other suggestion?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: name your frame! / sprite animation preview
« Reply #3 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
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: name your frame! / sprite animation preview
« Reply #4 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

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: name your frame! / sprite animation preview
« Reply #5 on: 2008-01-27, 08:26:42 AM »
Are you sure you put the code in SpriteState and not SpriteBase?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: name your frame! / sprite animation preview
« Reply #6 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.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: name your frame! / sprite animation preview
« Reply #7 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.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: name your frame! / sprite animation preview
« Reply #8 on: 2008-01-27, 09:00:52 AM »
m_frameIndexMap.Length works perfectly! thank you

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: name your frame! / sprite animation preview
« Reply #9 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 :)
Edward Dassmesser