mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Added AnimationState clear.
id return value for factory methods.
This commit is contained in:
parent
7193122908
commit
7bd6f62a2b
@ -52,6 +52,7 @@ void AnimationState_apply (AnimationState* self, struct Skeleton* skeleton);
|
|||||||
void AnimationState_setAnimationByName (AnimationState* self, const char* animationName, int/**/loop);
|
void AnimationState_setAnimationByName (AnimationState* self, const char* animationName, int/**/loop);
|
||||||
/* @param animation May be 0. */
|
/* @param animation May be 0. */
|
||||||
void AnimationState_setAnimation (AnimationState* self, Animation* animation, int/**/loop);
|
void AnimationState_setAnimation (AnimationState* self, Animation* animation, int/**/loop);
|
||||||
|
void AnimationState_clearAnimation (AnimationState* self);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,11 @@ void AnimationState_setAnimation (AnimationState* self, Animation* newAnimation,
|
|||||||
self->time = 0;
|
self->time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnimationState_clearAnimation (AnimationState* self) {
|
||||||
|
SUB_CAST(_Internal, self) ->previous = 0;
|
||||||
|
CONST_CAST(Animation*, self->animation) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
- (void) setMix:(NSString*)fromName to:(NSString*)toName duration:(float)duration;
|
- (void) setMix:(NSString*)fromName to:(NSString*)toName duration:(float)duration;
|
||||||
- (void) setAnimation:(NSString*)animationName loop:(bool)loop;
|
- (void) setAnimation:(NSString*)animationName loop:(bool)loop;
|
||||||
|
- (void) clearAnimation;
|
||||||
|
|
||||||
- (void) updateWorldTransform;
|
- (void) updateWorldTransform;
|
||||||
|
|
||||||
|
|||||||
@ -112,11 +112,11 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
|||||||
|
|
||||||
@implementation CCSkeleton
|
@implementation CCSkeleton
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(NSString*)skeletonDataFile atlas:(Atlas*)atlas {
|
+ (id) create:(NSString*)skeletonDataFile atlas:(Atlas*)atlas {
|
||||||
return [CCSkeleton create:skeletonDataFile atlas:atlas scale:1];
|
return [CCSkeleton create:skeletonDataFile atlas:atlas scale:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(NSString*)skeletonDataFile atlas:(Atlas*)atlas scale:(float)scale {
|
+ (id) create:(NSString*)skeletonDataFile atlas:(Atlas*)atlas scale:(float)scale {
|
||||||
NSAssert(skeletonDataFile, @"skeletonDataFile cannot be nil.");
|
NSAssert(skeletonDataFile, @"skeletonDataFile cannot be nil.");
|
||||||
NSAssert(atlas, @"atlas cannot be nil.");
|
NSAssert(atlas, @"atlas cannot be nil.");
|
||||||
|
|
||||||
@ -131,11 +131,11 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(NSString*)skeletonDataFile atlasFile:(NSString*)atlasFile {
|
+ (id) create:(NSString*)skeletonDataFile atlasFile:(NSString*)atlasFile {
|
||||||
return [CCSkeleton create:skeletonDataFile atlasFile:atlasFile scale:1];
|
return [CCSkeleton create:skeletonDataFile atlasFile:atlasFile scale:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(NSString*)skeletonDataFile atlasFile:(NSString*)atlasFile scale:(float)scale {
|
+ (id) create:(NSString*)skeletonDataFile atlasFile:(NSString*)atlasFile scale:(float)scale {
|
||||||
NSAssert(skeletonDataFile, @"skeletonDataFile cannot be nil.");
|
NSAssert(skeletonDataFile, @"skeletonDataFile cannot be nil.");
|
||||||
NSAssert(atlasFile, @"atlasFile cannot be nil.");
|
NSAssert(atlasFile, @"atlasFile cannot be nil.");
|
||||||
|
|
||||||
@ -159,11 +159,11 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(SkeletonData*)skeletonData {
|
+ (id) create:(SkeletonData*)skeletonData {
|
||||||
return [CCSkeleton create:skeletonData stateData:0];
|
return [CCSkeleton create:skeletonData stateData:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CCSkeleton*) create:(SkeletonData*)skeletonData stateData:(AnimationStateData*)stateData {
|
+ (id) create:(SkeletonData*)skeletonData stateData:(AnimationStateData*)stateData {
|
||||||
return [[[CCSkeleton alloc] init:skeletonData stateData:stateData] autorelease];
|
return [[[CCSkeleton alloc] init:skeletonData stateData:stateData] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,6 +330,9 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
|||||||
- (void) setAnimation:(NSString*)animationName loop:(bool)loop {
|
- (void) setAnimation:(NSString*)animationName loop:(bool)loop {
|
||||||
AnimationState_setAnimationByName(state, [animationName UTF8String], loop);
|
AnimationState_setAnimationByName(state, [animationName UTF8String], loop);
|
||||||
}
|
}
|
||||||
|
- (void) clearAnimation {
|
||||||
|
AnimationState_clearAnimation(state);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) updateWorldTransform {
|
- (void) updateWorldTransform {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
Skeleton_updateWorldTransform(skeleton);
|
||||||
|
|||||||
@ -299,6 +299,10 @@ void CCSkeleton::setAnimation (const char* animationName, bool loop) {
|
|||||||
AnimationState_setAnimationByName(state, animationName, loop);
|
AnimationState_setAnimationByName(state, animationName, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCSkeleton::clearAnimation () {
|
||||||
|
AnimationState_clearAnimation(state);
|
||||||
|
}
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void CCSkeleton::updateWorldTransform () {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
Skeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public:
|
|||||||
|
|
||||||
void setMix (const char* fromName, const char* toName, float duration);
|
void setMix (const char* fromName, const char* toName, float duration);
|
||||||
void setAnimation (const char* animationName, bool loop);
|
void setAnimation (const char* animationName, bool loop);
|
||||||
|
void clearAnimation ();
|
||||||
|
|
||||||
void updateWorldTransform ();
|
void updateWorldTransform ();
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ namespace Spine {
|
|||||||
Time = 0;
|
Time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear () {
|
public void ClearAnimation () {
|
||||||
previous = null;
|
previous = null;
|
||||||
Animation = null;
|
Animation = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class AnimationState {
|
|||||||
current.apply(skeleton, currentTime, currentLoop);
|
current.apply(skeleton, currentTime, currentLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear () {
|
public void clearAnimation () {
|
||||||
previous = null;
|
previous = null;
|
||||||
current = null;
|
current = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
|
|
||||||
// Keep AnimationState in sync with animationName and loop fields.
|
// Keep AnimationState in sync with animationName and loop fields.
|
||||||
if (animationName == null && state.Animation != null)
|
if (animationName == null && state.Animation != null)
|
||||||
state.Clear();
|
state.ClearAnimation();
|
||||||
else if (state.Animation == null || animationName != state.Animation.Name) {
|
else if (state.Animation == null || animationName != state.Animation.Name) {
|
||||||
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
||||||
if (animation != null)
|
if (animation != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user