mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[cocos2dx] Closes #1216. Cocos2dx may draw a SkeletonAnimation node before its update method is called. The skeleton is thus rendered in the setup pose for the first frame.
This commit is contained in:
parent
3ff14fc186
commit
9d54f47114
@ -116,6 +116,8 @@ void SkeletonAnimation::initialize () {
|
||||
_state->listener = animationCallback;
|
||||
|
||||
_spAnimationState* stateInternal = (_spAnimationState*)_state;
|
||||
|
||||
_firstDraw = true;
|
||||
}
|
||||
|
||||
SkeletonAnimation::SkeletonAnimation ()
|
||||
@ -136,6 +138,14 @@ void SkeletonAnimation::update (float deltaTime) {
|
||||
spSkeleton_updateWorldTransform(_skeleton);
|
||||
}
|
||||
|
||||
void SkeletonAnimation::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t transformFlags) {
|
||||
if (_firstDraw) {
|
||||
_firstDraw = false;
|
||||
update(0);
|
||||
}
|
||||
super::draw(renderer, transform, transformFlags);
|
||||
}
|
||||
|
||||
void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
||||
CCASSERT(stateData, "stateData cannot be null.");
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void update (float deltaTime) override;
|
||||
virtual void draw (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags) override;
|
||||
|
||||
void setAnimationStateData (spAnimationStateData* stateData);
|
||||
void setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration);
|
||||
@ -109,6 +110,7 @@ protected:
|
||||
spAnimationState* _state;
|
||||
|
||||
bool _ownsAnimationStateData;
|
||||
bool _firstDraw;
|
||||
|
||||
StartListener _startListener;
|
||||
InterruptListener _interruptListener;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user