Scrolling Game Development Kit Forum
SGDK Version 2 => General Discussion => Topic started 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?
-
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.
-
i must have been beaten with blindness. what about the other suggestion?
-
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 '}'):
public int AnimationLength
{
get
{
return m_frames.Length;
}
}
Then create a rule like:
Rule Type: If
Rule: ==
Left operand: frame
Right operand: CurrentState.AnimationLength
-
error:
SpriteBase.cs(2436,17) : error CS0246: The type or namespace name 'm_frames' could not be found
-
Are you sure you put the code in SpriteState and not SpriteBase?
-
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.
-
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.
-
m_frameIndexMap.Length works perfectly! thank you
-
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 :)