mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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_setAnimation (AnimationState* self, Animation* animation, int/**/loop);
|
||||||
void AnimationState_clearAnimation (AnimationState* self);
|
void AnimationState_clearAnimation (AnimationState* self);
|
||||||
|
|
||||||
|
int/*bool*/AnimationState_isComplete (AnimationState* self);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,10 @@ void AnimationState_clearAnimation (AnimationState* self) {
|
|||||||
CONST_CAST(Animation*, self->animation) = 0;
|
CONST_CAST(Animation*, self->animation) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int/*bool*/AnimationState_isComplete (AnimationState* self) {
|
||||||
|
return !self->animation || self->time >= self->animation->duration;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -60,6 +60,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) clearAnimation;
|
||||||
|
- (void) isComplete;
|
||||||
|
|
||||||
- (void) updateWorldTransform;
|
- (void) updateWorldTransform;
|
||||||
|
|
||||||
|
|||||||
@ -333,6 +333,9 @@ void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_
|
|||||||
- (void) clearAnimation {
|
- (void) clearAnimation {
|
||||||
AnimationState_clearAnimation(state);
|
AnimationState_clearAnimation(state);
|
||||||
}
|
}
|
||||||
|
- (void) isComplete {
|
||||||
|
return AnimationState_isComplete(state);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) updateWorldTransform {
|
- (void) updateWorldTransform {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
Skeleton_updateWorldTransform(skeleton);
|
||||||
|
|||||||
@ -63,7 +63,7 @@ bool ExampleLayer::init () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExampleLayer::update (float deltaTime) {
|
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);
|
if (skeletonNode->state->time > 2) skeletonNode->setAnimation("jump", false);
|
||||||
} else {
|
} else {
|
||||||
if (skeletonNode->state->time > 1) skeletonNode->setAnimation("walk", true);
|
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) {
|
void CCSkeleton::setMix (const char* fromName, const char* toName, float duration) {
|
||||||
AnimationStateData_setMixByName(state->data, fromName, toName, duration);
|
AnimationStateData_setMixByName(state->data, fromName, toName, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setAnimation (const char* animationName, bool loop) {
|
void CCSkeleton::setAnimation (const char* animationName, bool loop) {
|
||||||
AnimationState_setAnimationByName(state, animationName, loop);
|
AnimationState_setAnimationByName(state, animationName, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::clearAnimation () {
|
void CCSkeleton::clearAnimation () {
|
||||||
AnimationState_clearAnimation(state);
|
AnimationState_clearAnimation(state);
|
||||||
}
|
}
|
||||||
|
bool CCSkeleton::isComplete () const {
|
||||||
|
return AnimationState_isComplete(state) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void CCSkeleton::updateWorldTransform () {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
Skeleton_updateWorldTransform(skeleton);
|
||||||
|
|||||||
@ -54,6 +54,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 clearAnimation ();
|
||||||
|
bool isComplete () const;
|
||||||
|
|
||||||
void updateWorldTransform ();
|
void updateWorldTransform ();
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,11 @@ namespace Spine {
|
|||||||
Animation = null;
|
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 () {
|
override public String ToString () {
|
||||||
return (Animation != null && Animation.Name != null) ? Animation.Name : base.ToString();
|
return (Animation != null && Animation.Name != null) ? Animation.Name : base.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,11 @@ public class AnimationState {
|
|||||||
currentTime = time;
|
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 () {
|
public AnimationStateData getData () {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,7 @@ public class SkeletonTest extends ApplicationAdapter {
|
|||||||
skeleton = new Skeleton(skeletonData);
|
skeleton = new Skeleton(skeletonData);
|
||||||
if (name.equals("goblins")) skeleton.setSkin("goblin");
|
if (name.equals("goblins")) skeleton.setSkin("goblin");
|
||||||
skeleton.setToBindPose();
|
skeleton.setToBindPose();
|
||||||
|
skeleton = new Skeleton(skeleton);
|
||||||
|
|
||||||
Bone root = skeleton.getRootBone();
|
Bone root = skeleton.getRootBone();
|
||||||
root.x = 50;
|
root.x = 50;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ void spineboy () {
|
|||||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||||
deltaClock.restart();
|
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);
|
if (drawable->state->time > 2) AnimationState_setAnimationByName(drawable->state, "jump", false);
|
||||||
} else {
|
} else {
|
||||||
if (drawable->state->time > 1) AnimationState_setAnimationByName(drawable->state, "walk", true);
|
if (drawable->state->time > 1) AnimationState_setAnimationByName(drawable->state, "walk", true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user