Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover last Frame of Animation #7

Open
LucasMW opened this issue Oct 6, 2015 · 5 comments
Open

Discover last Frame of Animation #7

LucasMW opened this issue Oct 6, 2015 · 5 comments

Comments

@LucasMW
Copy link

LucasMW commented Oct 6, 2015

There's no way of doing a loop for every frame by using jumpToNextFrame
something like
node.jumpToFrame(0)
for i = 0 ; i < node.currentAnimationFrameCount; i++
{
node.jumpToNextFrame()
// do something
}

In my project I need to custom render an animation to UIImages
And this would have been one of its uses...

@mredig
Copy link
Owner

mredig commented Oct 6, 2015

I'm not entirely sure, but I expect you'd be able to programmatically figure it out with this info:
@Property (nonatomic, strong, readonly) NSMutableArray* currentAnimationSequence; (array size for all frames)
@Property (nonatomic) CGFloat timeResolution; //defaults to 1/120 for smooth playback at 60 fps. If you are planning to have slower motion or ramp, you should increase the resolution (lower values are higher resolution). At 1/120, you will start noticing stutters at speeds lower than 0.5x.
-(void)jumpToFrame:(NSInteger)frame;

It's been a long time since I've done anything with this project, so there is a chance for misinformation in this post. Please let me know if it works.

@LucasMW
Copy link
Author

LucasMW commented Oct 7, 2015

The currentAnimationSequence property is an array of Strings. These strings are the names of the animation running on the SGG_Spine. So array size gives me the number of animations running in sequence regardless of how many frames there are.
The readme.md specifies "If there is a sequence of animations running, this is an NSArray that will list their names.Will be nil if there is no sequence running. Does not activate for queued animations."
It isn't related to the frames at all.

@mredig
Copy link
Owner

mredig commented Oct 7, 2015

Ah. I appear to have forgotten more than I thought I did! However, I do know that I set it up all frames as an array of dictionaries or objects or something that defined each frame of the sequence... So, I would suggest taking a look around, trying to find that array as that will have the total count of frames in the sequence.

@LucasMW
Copy link
Author

LucasMW commented Oct 7, 2015

Also, there is no upper-limit protection implemented on jumpToNextFrame()

if I try to loop by using the comparing currentFrame to a variable workaround it won't work too.
var i = 0
node.jumpToFrame(0)
while(i == node.currentFrame())
{
//do something
i++
}
It would result in infinite loop.
Some days ago I searched the code and saw there wasn't upper bound protection

Within this search I found there was a variable called totalFrames which is used on debug mode. I changed SpineImport code to export this variable to my code, but it didn't work the way I expected.
I think this info is important to report.

Anyway, I will try to find this array of the frames.

@mredig
Copy link
Owner

mredig commented Oct 7, 2015

In all honesty, this project started as an idea for an implementation for a Spine runtime that quickly turned into a hodgepodge of clunky code. In the end, somehow it worked anyway! However, I don't currently have the time to devote any effort to it (and if I did, I'd probably start over from scratch). You're more than welcome to submit pull requests to fix issues and I'll just trust that you got it to work right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants