mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
isComplete for AnimationState.
This commit is contained in:
parent
1071f3474f
commit
5a46f8c6b4
@ -54,6 +54,8 @@ void AnimationState_setAnimationByName (AnimationState* self, const char* animat
|
||||
void AnimationState_setAnimation (AnimationState* self, Animation* animation, int/**/loop);
|
||||
void AnimationState_clearAnimation (AnimationState* self);
|
||||
|
||||
int/*bool*/AnimationState_isComplete (AnimationState* self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,10 @@ void AnimationState_clearAnimation (AnimationState* self) {
|
||||
CONST_CAST(Animation*, self->animation) = 0;
|
||||
}
|
||||
|
||||
int/*bool*/AnimationState_isComplete (AnimationState* self) {
|
||||
return !self->animation || self->time >= self->animation->duration;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
- (void) setMix:(NSString*)fromName to:(NSString*)toName duration:(float)duration;
|
||||
- (void) setAnimation:(NSString*)animationName loop:(bool)loop;
|
||||
- (void) clearAnimation;
|
||||
- (void) isComplete;
|
||||
|
||||
- (void) updateWorldTransform;
|
||||
|
||||
|
||||
@ -333,6 +333,9 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
||||
- (void) clearAnimation {
|
||||
AnimationState_clearAnimation(state);
|
||||
}
|
||||
- (void) isComplete {
|
||||
return AnimationState_isComplete(state);
|
||||
}
|
||||
|
||||
- (void) updateWorldTransform {
|
||||
Skeleton_updateWorldTransform(skeleton);
|
||||
|
||||
@ -63,7 +63,7 @@ bool ExampleLayer::init () {
|
||||
}
|
||||
|
||||
void ExampleLayer::update (float deltaTime) {
|
||||
if (strcmp(skeletonNode->state->animation->name, "walk") == 0) {
|
||||
if (skeletonNode->state->loop) {
|
||||
if (skeletonNode->state->time > 2) skeletonNode->setAnimation("jump", false);
|
||||
} else {
|
||||
if (skeletonNode->state->time > 1) skeletonNode->setAnimation("walk", true);
|
||||
|
||||
@ -294,14 +294,15 @@ CCRect CCSkeleton::boundingBox () {
|
||||
void CCSkeleton::setMix (const char* fromName, const char* toName, float duration) {
|
||||
AnimationStateData_setMixByName(state->data, fromName, toName, duration);
|
||||
}
|
||||
|
||||
void CCSkeleton::setAnimation (const char* animationName, bool loop) {
|
||||
AnimationState_setAnimationByName(state, animationName, loop);
|
||||
}
|
||||
|
||||
void CCSkeleton::clearAnimation () {
|
||||
AnimationState_clearAnimation(state);
|
||||
}
|
||||
bool CCSkeleton::isComplete () const {
|
||||
return AnimationState_isComplete(state) != 0;
|
||||
}
|
||||
|
||||
void CCSkeleton::updateWorldTransform () {
|
||||
Skeleton_updateWorldTransform(skeleton);
|
||||
|
||||
@ -54,6 +54,7 @@ public:
|
||||
void setMix (const char* fromName, const char* toName, float duration);
|
||||
void setAnimation (const char* animationName, bool loop);
|
||||
void clearAnimation ();
|
||||
bool isComplete () const;
|
||||
|
||||
void updateWorldTransform ();
|
||||
|
||||
|
||||
@ -89,6 +89,11 @@ namespace Spine {
|
||||
Animation = null;
|
||||
}
|
||||
|
||||
/** Returns true if no animation is set or if the current time is greater than the animation duration, regardless of looping. */
|
||||
public bool isComplete () {
|
||||
return Animation == null || Time >= Animation.Duration;
|
||||
}
|
||||
|
||||
override public String ToString () {
|
||||
return (Animation != null && Animation.Name != null) ? Animation.Name : base.ToString();
|
||||
}
|
||||
|
||||
@ -104,6 +104,11 @@ public class AnimationState {
|
||||
currentTime = time;
|
||||
}
|
||||
|
||||
/** Returns true if no animation is set or if the current time is greater than the animation duration, regardless of looping. */
|
||||
public boolean isComplete () {
|
||||
return current == null || currentTime >= current.getDuration();
|
||||
}
|
||||
|
||||
public AnimationStateData getData () {
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ public class SkeletonTest extends ApplicationAdapter {
|
||||
skeleton = new Skeleton(skeletonData);
|
||||
if (name.equals("goblins")) skeleton.setSkin("goblin");
|
||||
skeleton.setToBindPose();
|
||||
skeleton = new Skeleton(skeleton);
|
||||
|
||||
Bone root = skeleton.getRootBone();
|
||||
root.x = 50;
|
||||
|
||||
@ -69,7 +69,7 @@ void spineboy () {
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
|
||||
if (strcmp(drawable->state->animation->name, "walk") == 0) {
|
||||
if (drawable->state->loop) {
|
||||
if (drawable->state->time > 2) AnimationState_setAnimationByName(drawable->state, "jump", false);
|
||||
} else {
|
||||
if (drawable->state->time > 1) AnimationState_setAnimationByName(drawable->state, "walk", true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user