Skip to content

Commit

Permalink
Added getAnimationState.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Jun 11, 2013
1 parent fa0267e commit d073292
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
5 changes: 5 additions & 0 deletions spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
1 change: 1 addition & 0 deletions spine-cocos2dx/src/spine/CCSkeletonAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d073292

Please sign in to comment.