From d0732921c98fc54f68cb426fd32616e2ca92d0fa Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 11 Jun 2013 18:23:40 +0200 Subject: [PATCH] Added getAnimationState. --- spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h | 1 + spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m | 5 +++++ spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp | 5 +++++ spine-cocos2dx/src/spine/CCSkeletonAnimation.h | 1 + 4 files changed, 12 insertions(+) diff --git a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h index 8c4f2a6fd3..70f627126a 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h +++ b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h @@ -46,6 +46,7 @@ Draws an animated skeleton, providing a simple API for applying one or more anim - (void) addAnimationState; - (void) addAnimationState:(AnimationStateData*)stateData; +- (AnimationState*) getAnimationState:(int)stateIndex; - (void) setAnimationStateData:(AnimationStateData*)stateData forState:(int)stateIndex; - (void) setMixFrom:(NSString*)fromAnimation to:(NSString*)toAnimation duration:(float)duration; diff --git a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m index 46e1c5afa1..e690a6b4d2 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m +++ b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m @@ -115,6 +115,11 @@ - (void) addAnimationState:(AnimationStateData*)stateData { [_states addObject:[NSValue valueWithPointer:state]]; } +- (AnimationState*) getAnimationState:(int)stateIndex { + NSAssert(stateIndex >= 0 && stateIndex < (int)_states.count, @"stateIndex out of range."); + return [[_states objectAtIndex:stateIndex] pointerValue]; +} + - (void) setAnimationStateData:(AnimationStateData*)stateData forState:(int)stateIndex { NSAssert(stateData, @"stateData cannot be null."); NSAssert(stateIndex >= 0 && stateIndex < (int)_states.count, @"stateIndex out of range."); diff --git a/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp b/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp index 5eddd7f38c..9494f1dfdd 100644 --- a/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp +++ b/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp @@ -95,6 +95,11 @@ void CCSkeletonAnimation::addAnimationState (AnimationStateData* stateData) { states.push_back(state); } +AnimationState* getAnimationState (int stateIndex) { + CCAssert(stateIndex >= 0 && stateIndex < (int)states.size(), "stateIndex out of range."); + return states[stateIndex]; +} + void CCSkeletonAnimation::setAnimationStateData (AnimationStateData* stateData, int stateIndex) { CCAssert(stateIndex >= 0 && stateIndex < (int)states.size(), "stateIndex out of range."); CCAssert(stateData, "stateData cannot be null."); diff --git a/spine-cocos2dx/src/spine/CCSkeletonAnimation.h b/spine-cocos2dx/src/spine/CCSkeletonAnimation.h index e48645943f..f93247a4c7 100644 --- a/spine-cocos2dx/src/spine/CCSkeletonAnimation.h +++ b/spine-cocos2dx/src/spine/CCSkeletonAnimation.h @@ -53,6 +53,7 @@ class CCSkeletonAnimation: public CCSkeleton { void addAnimationState (AnimationStateData* stateData = 0); void setAnimationStateData (AnimationStateData* stateData, int stateIndex = 0); + AnimationState* getAnimationState (int stateIndex = 0); void setMix (const char* fromAnimation, const char* toAnimation, float duration, int stateIndex = 0); void setAnimation (const char* name, bool loop, int stateIndex = 0); void addAnimation (const char* name, bool loop, float delay = 0, int stateIndex = 0);