mirror of https://github.com/axmolengine/axmol.git
fixed change animation internal, animation speed not right
This commit is contained in:
parent
1bdf1a44a1
commit
6a3aff0861
|
@ -163,28 +163,6 @@ float ArmatureAnimation::getSpeedScale() const
|
|||
return _speedScale;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::setAnimationInternal(float animationInternal)
|
||||
{
|
||||
if(animationInternal == _animationInternal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_animationInternal = animationInternal;
|
||||
|
||||
DictElement *element = nullptr;
|
||||
const Dictionary *dict = _armature->getBoneDic();
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
bone->getTween()->setAnimationInternal(_animationInternal);
|
||||
if (bone->getChildArmature())
|
||||
{
|
||||
bone->getChildArmature()->getAnimation()->setAnimationInternal(_animationInternal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ArmatureAnimation::play(const char *animationName, int durationTo, int durationTween, int loop, int tweenEasing)
|
||||
{
|
||||
|
@ -250,12 +228,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing);
|
||||
|
||||
tween->setProcessScale(_processScale);
|
||||
tween->setAnimationInternal(_animationInternal);
|
||||
|
||||
if (bone->getChildArmature())
|
||||
{
|
||||
bone->getChildArmature()->getAnimation()->setProcessScale(_processScale);
|
||||
bone->getChildArmature()->getAnimation()->setAnimationInternal(_animationInternal);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
virtual float getSpeedScale() const;
|
||||
|
||||
//! The animation update speed
|
||||
virtual void setAnimationInternal(float animationInternal);
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setAnimationInternal(float animationInternal) {}
|
||||
|
||||
using ProcessBase::play;
|
||||
/**
|
||||
|
|
|
@ -38,16 +38,12 @@ ProcessBase::ProcessBase(void)
|
|||
, _rawDuration(0)
|
||||
, _loopType(ANIMATION_LOOP_BACK)
|
||||
, _tweenEasing(Linear)
|
||||
, _animationInternal(1/60.0f)
|
||||
, _durationTween(0)
|
||||
, _currentFrame(0)
|
||||
, _curFrameIndex(0)
|
||||
, _isLoopBack(false)
|
||||
{
|
||||
/*
|
||||
* set _animationInternal defualt value to Director::getInstance()
|
||||
* ->getAnimationInterval(), in line with game update speed
|
||||
*/
|
||||
_animationInternal = CCDirector::getInstance()->getAnimationInterval();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -124,8 +124,6 @@ public:
|
|||
virtual float getCurrentPercent() const { return _currentPercent; }
|
||||
virtual int getRawDuration() const { return _rawDuration; }
|
||||
|
||||
virtual void setAnimationInternal(float animationInternal) { _animationInternal = animationInternal; }
|
||||
virtual float getAnimationInternal() const { return _animationInternal; }
|
||||
protected:
|
||||
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
|
|
|
@ -71,6 +71,10 @@ Layer *CreateLayer(int index)
|
|||
break;
|
||||
case TEST_EASING:
|
||||
pLayer = new TestEasing();
|
||||
break;
|
||||
case TEST_CHANGE_ANIMATION_INTERNAL:
|
||||
pLayer = new TestChangeAnimationInternal();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1385,6 +1389,10 @@ void TestEasing::onEnter()
|
|||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesEnded = CC_CALLBACK_2(TestPlaySeveralMovement::onTouchesEnded, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
animationID = 0;
|
||||
|
||||
armature = Armature::create("testEasing");
|
||||
|
@ -1420,3 +1428,45 @@ void TestEasing::updateSubTitle()
|
|||
label->setString(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TestChangeAnimationInternal::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesEnded = CC_CALLBACK_2(TestPlaySeveralMovement::onTouchesEnded, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
Armature *armature = NULL;
|
||||
armature = Armature::create("Cowboy");
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setScale(0.2f);
|
||||
|
||||
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y));
|
||||
addChild(armature);
|
||||
}
|
||||
void TestChangeAnimationInternal::onExit()
|
||||
{
|
||||
Director::getInstance()->setAnimationInterval(1/60.0f);
|
||||
}
|
||||
std::string TestChangeAnimationInternal::title()
|
||||
{
|
||||
return "Test change animation internal";
|
||||
}
|
||||
std::string TestChangeAnimationInternal::subtitle()
|
||||
{
|
||||
return "Touch to change animation internal";
|
||||
}
|
||||
void TestChangeAnimationInternal::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
||||
{
|
||||
if (Director::getInstance()->getAnimationInterval() == 1/30.0f)
|
||||
{
|
||||
Director::getInstance()->setAnimationInterval(1/60.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Director::getInstance()->setAnimationInterval(1/30.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ enum {
|
|||
TEST_ARMATURE_NESTING_2,
|
||||
TEST_PLAY_SEVERAL_MOVEMENT,
|
||||
TEST_EASING,
|
||||
TEST_CHANGE_ANIMATION_INTERNAL,
|
||||
|
||||
TEST_LAYER_COUNT
|
||||
};
|
||||
|
@ -372,4 +373,15 @@ public:
|
|||
cocostudio::Armature *armature;
|
||||
};
|
||||
|
||||
class TestChangeAnimationInternal : public ArmatureTestLayer
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
||||
};
|
||||
|
||||
#endif // __HELLOWORLD_SCENE_H__
|
Loading…
Reference in New Issue