From 324732b867d9145ac231e87daa64aa71113e9f50 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Wed, 18 Dec 2013 23:29:54 +0800 Subject: [PATCH] change play arguments --- .../cocostudio/CCArmatureAnimation.cpp | 20 +++++++++---------- .../cocostudio/CCArmatureAnimation.h | 5 +++-- .../CocoStudioArmatureTest/ArmatureScene.cpp | 10 ++++++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 8e3ecb786b..624c2cf6a6 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -57,6 +57,7 @@ ArmatureAnimation::ArmatureAnimation() , _ignoreFrameEvent(false) , _onMovementList(false) , _movementListLoop(false) + , _movementListDurationTo(-1) , _userObject(nullptr) , _movementEventCallFunc(nullptr) @@ -256,33 +257,32 @@ void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop } -void ArmatureAnimation::play(bool loop, const std::string *movementNames, int movementNumber) +void ArmatureAnimation::play(const std::vector& movementNames, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; + _movementListDurationTo = durationTo; _onMovementList = true; _movementIndex = 0; - for (int i = 0; i& movementIndexes, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; + _movementListDurationTo = durationTo; _onMovementList = true; _movementIndex = 0; std::vector &movName = _animationData->movementNames; - for (int i = 0; i= _movementList.size()) @@ -523,7 +523,7 @@ void ArmatureAnimation::updateMovementList() { if (_movementIndex < _movementList.size()) { - play(_movementList.at(_movementIndex).c_str(), -1, 0); + play(_movementList.at(_movementIndex).c_str(), _movementListDurationTo, 0); _movementIndex++; } else diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 9cce0b9df4..25955ecc49 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -132,8 +132,8 @@ public: virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1); - virtual void play(bool loop, const std::string *movementNames, int movementNumber); - virtual void playByIndex(bool loop, const int *movementIndexes, int movementNumber); + virtual void play(const std::vector& movementNames, int durationTo = -1, bool loop = true); + virtual void playByIndex(const std::vector& movementIndexes, int durationTo = -1, bool loop = true); /** * Go to specified frame and play current movement. @@ -293,6 +293,7 @@ protected: bool _onMovementList; bool _movementListLoop; unsigned int _movementIndex; + int _movementListDurationTo; cocos2d::Object *_userObject; protected: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 5eea71f764..5ffb101ae0 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1360,13 +1360,15 @@ void TestPlaySeveralMovement::onEnter() listener->onTouchesEnded = CC_CALLBACK_2(TestPlaySeveralMovement::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - std::string names[] = {"Walk", "FireMax", "Fire"}; - //int indexes[] = {0, 1, 2}; + std::string name[] = {"Walk", "FireMax", "Fire"}; + std::vector names(name, name+3); +// int index[] = {0, 1, 2}; +// std::vector indexes(index, index+3); Armature *armature = NULL; armature = Armature::create("Cowboy"); - armature->getAnimation()->play(true, names, 3); - //armature->getAnimation()->playByIndex(true, indexes, 3); + armature->getAnimation()->play(names); +// armature->getAnimation()->playByIndex(indexes); armature->setScale(0.2f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/));