change play interface name

This commit is contained in:
yinkaile 2013-12-25 16:46:31 +08:00
parent ef743b84ce
commit 13408e4dc5
4 changed files with 40 additions and 35 deletions

View File

@ -246,8 +246,12 @@ void ArmatureAnimation::play(const std::string& animationName, int durationTo,
_armature->update(0); _armature->update(0);
} }
void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop) void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop)
{
playWithIndex(animationIndex, durationTo, loop);
}
void ArmatureAnimation::playWithIndex(int animationIndex, int durationTo, int loop)
{ {
std::vector<std::string> &movName = _animationData->movementNames; std::vector<std::string> &movName = _animationData->movementNames;
CC_ASSERT((animationIndex > -1) && ((unsigned int)animationIndex < movName.size())); CC_ASSERT((animationIndex > -1) && ((unsigned int)animationIndex < movName.size()));
@ -257,7 +261,7 @@ void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop
} }
void ArmatureAnimation::play(const std::vector<std::string>& movementNames, int durationTo, bool loop) void ArmatureAnimation::playWithNames(const std::vector<std::string>& movementNames, int durationTo, bool loop)
{ {
_movementList.clear(); _movementList.clear();
_movementListLoop = loop; _movementListLoop = loop;
@ -270,7 +274,7 @@ void ArmatureAnimation::play(const std::vector<std::string>& movementNames, int
updateMovementList(); updateMovementList();
} }
void ArmatureAnimation::playByIndex(const std::vector<int>& movementIndexes, int durationTo, bool loop) void ArmatureAnimation::playWithIndexes(const std::vector<int>& movementIndexes, int durationTo, bool loop)
{ {
_movementList.clear(); _movementList.clear();
_movementListLoop = loop; _movementListLoop = loop;

View File

@ -127,13 +127,14 @@ public:
/** /**
* Play animation by index, the other param is the same to play. * Play animation by index, the other param is the same to play.
* Deprecated, please use
* @param animationIndex the animation index you want to play * @param animationIndex the animation index you want to play
*/ */
virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1); CC_DEPRECATED_ATTRIBUTE virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1);
virtual void playWithIndex(int animationIndex, int durationTo = -1, int loop = -1);
virtual void playWithNames(const std::vector<std::string>& movementNames, int durationTo = -1, bool loop = true);
virtual void play(const std::vector<std::string>& movementNames, int durationTo = -1, bool loop = true); virtual void playWithIndexes(const std::vector<int>& movementIndexes, int durationTo = -1, bool loop = true);
virtual void playByIndex(const std::vector<int>& movementIndexes, int durationTo = -1, bool loop = true);
/** /**
* Go to specified frame and play current movement. * Go to specified frame and play current movement.

View File

@ -308,7 +308,7 @@ void TestDirectLoading::onEnter()
ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/bear.ExportJson"); ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/bear.ExportJson");
Armature *armature = Armature::create("bear"); Armature *armature = Armature::create("bear");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y));
addChild(armature); addChild(armature);
} }
@ -323,7 +323,7 @@ void TestCSWithSkeleton::onEnter()
ArmatureTestLayer::onEnter(); ArmatureTestLayer::onEnter();
Armature *armature = nullptr; Armature *armature = nullptr;
armature = Armature::create("Cowboy"); armature = Armature::create("Cowboy");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setScale(0.2f); armature->setScale(0.2f);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/));
@ -344,7 +344,7 @@ void TestDragonBones20::onEnter()
Armature *armature = nullptr; Armature *armature = nullptr;
armature = Armature::create("Dragon"); armature = Armature::create("Dragon");
armature->getAnimation()->playByIndex(1); armature->getAnimation()->playWithIndex(1);
armature->getAnimation()->setSpeedScale(0.4f); armature->getAnimation()->setSpeedScale(0.4f);
armature->setPosition(VisibleRect::center().x, VisibleRect::center().y * 0.3f); armature->setPosition(VisibleRect::center().x, VisibleRect::center().y * 0.3f);
armature->setScale(0.6f); armature->setScale(0.6f);
@ -418,7 +418,7 @@ void TestPerformance::addArmature(int number)
Armature *armature = nullptr; Armature *armature = nullptr;
armature = new Armature(); armature = new Armature();
armature->init("Knight_f/Knight"); armature->init("Knight_f/Knight");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(50 + armatureCount * 2, 150); armature->setPosition(50 + armatureCount * 2, 150);
armature->setScale(0.6f); armature->setScale(0.6f);
addArmatureToParent(armature); addArmatureToParent(armature);
@ -473,21 +473,21 @@ void TestChangeZorder::onEnter()
currentTag = -1; currentTag = -1;
armature = Armature::create("Knight_f/Knight"); armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100));
++currentTag; ++currentTag;
armature->setScale(0.6f); armature->setScale(0.6f);
addChild(armature, currentTag, currentTag); addChild(armature, currentTag, currentTag);
armature = Armature::create("Cowboy"); armature = Armature::create("Cowboy");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setScale(0.24f); armature->setScale(0.24f);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100));
++currentTag; ++currentTag;
addChild(armature, currentTag, currentTag); addChild(armature, currentTag, currentTag);
armature = Armature::create("Dragon"); armature = Armature::create("Dragon");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(Point(VisibleRect::center().x , VisibleRect::center().y - 100)); armature->setPosition(Point(VisibleRect::center().x , VisibleRect::center().y - 100));
++currentTag; ++currentTag;
armature->setScale(0.6f); armature->setScale(0.6f);
@ -626,7 +626,7 @@ void TestParticleDisplay::onEnter()
animationID = 0; animationID = 0;
armature = Armature::create("robot"); armature = Armature::create("robot");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center()); armature->setPosition(VisibleRect::center());
armature->setScale(0.48f); armature->setScale(0.48f);
armature->getAnimation()->setSpeedScale(0.5f); armature->getAnimation()->setSpeedScale(0.5f);
@ -672,7 +672,7 @@ void TestParticleDisplay::onTouchesEnded(const std::vector<Touch*>& touches, Eve
{ {
++animationID; ++animationID;
animationID = animationID % armature->getAnimation()->getMovementCount(); animationID = animationID % armature->getAnimation()->getMovementCount();
armature->getAnimation()->playByIndex(animationID); armature->getAnimation()->playWithIndex(animationID);
} }
void TestUseMutiplePicture::onEnter() void TestUseMutiplePicture::onEnter()
@ -686,7 +686,7 @@ void TestUseMutiplePicture::onEnter()
displayIndex = 0; displayIndex = 0;
armature = Armature::create("Knight_f/Knight"); armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::left().y)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::left().y));
armature->setScale(1.2f); armature->setScale(1.2f);
addChild(armature); addChild(armature);
@ -1083,7 +1083,7 @@ void TestBoundingBox::onEnter()
ArmatureTestLayer::onEnter(); ArmatureTestLayer::onEnter();
armature = Armature::create("Cowboy"); armature = Armature::create("Cowboy");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center()); armature->setPosition(VisibleRect::center());
armature->setScale(0.2f); armature->setScale(0.2f);
addChild(armature); addChild(armature);
@ -1114,7 +1114,7 @@ void TestAnchorPoint::onEnter()
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
Armature *armature = Armature::create("Cowboy"); Armature *armature = Armature::create("Cowboy");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center()); armature->setPosition(VisibleRect::center());
armature->setScale(0.2f); armature->setScale(0.2f);
addChild(armature, 0, i); addChild(armature, 0, i);
@ -1141,7 +1141,7 @@ void TestArmatureNesting::onEnter()
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
armature = Armature::create("cyborg"); armature = Armature::create("cyborg");
armature->getAnimation()->playByIndex(1); armature->getAnimation()->playWithIndex(1);
armature->setPosition(VisibleRect::center()); armature->setPosition(VisibleRect::center());
armature->setScale(1.2f); armature->setScale(1.2f);
armature->getAnimation()->setSpeedScale(0.4f); armature->getAnimation()->setSpeedScale(0.4f);
@ -1167,8 +1167,8 @@ void TestArmatureNesting::onTouchesEnded(const std::vector<Touch*>& touches, Eve
if(armature != nullptr) if(armature != nullptr)
{ {
armature->getBone("armInside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex); armature->getBone("armInside")->getChildArmature()->getAnimation()->playWithIndex(weaponIndex);
armature->getBone("armOutside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex); armature->getBone("armOutside")->getChildArmature()->getAnimation()->playWithIndex(weaponIndex);
} }
} }
@ -1199,7 +1199,7 @@ void Hero::changeMount(Armature *armature)
{ {
retain(); retain();
playByIndex(0); playWithIndex(0);
//Remove hero from display list //Remove hero from display list
m_pMount->getBone("hero")->removeDisplay(0); m_pMount->getBone("hero")->removeDisplay(0);
m_pMount->stopAllActions(); m_pMount->stopAllActions();
@ -1231,7 +1231,7 @@ void Hero::changeMount(Armature *armature)
setPosition(Point(0,0)); setPosition(Point(0,0));
//Change animation //Change animation
playByIndex(1); playWithIndex(1);
setScale(1); setScale(1);
@ -1240,12 +1240,12 @@ void Hero::changeMount(Armature *armature)
} }
void Hero::playByIndex(int index) void Hero::playWithIndex(int index)
{ {
_animation->playByIndex(index); _animation->playWithIndex(index);
if (m_pMount) if (m_pMount)
{ {
m_pMount->getAnimation()->playByIndex(index); m_pMount->getAnimation()->playWithIndex(index);
} }
} }
@ -1272,7 +1272,7 @@ void TestArmatureNesting2::onEnter()
//Create a hero //Create a hero
hero = Hero::create("hero"); hero = Hero::create("hero");
hero->setLayer(this); hero->setLayer(this);
hero->playByIndex(0); hero->playWithIndex(0);
hero->setPosition(Point(VisibleRect::left().x + 20, VisibleRect::left().y)); hero->setPosition(Point(VisibleRect::left().x + 20, VisibleRect::left().y));
addChild(hero); addChild(hero);
@ -1345,7 +1345,7 @@ void TestArmatureNesting2::ChangeMountCallback(Object* pSender)
Armature * TestArmatureNesting2::createMount(const char *name, Point position) Armature * TestArmatureNesting2::createMount(const char *name, Point position)
{ {
Armature *armature = Armature::create(name); Armature *armature = Armature::create(name);
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setPosition(position); armature->setPosition(position);
addChild(armature); addChild(armature);
@ -1368,8 +1368,8 @@ void TestPlaySeveralMovement::onEnter()
Armature *armature = NULL; Armature *armature = NULL;
armature = Armature::create("Cowboy"); armature = Armature::create("Cowboy");
armature->getAnimation()->play(names); armature->getAnimation()->playWithNames(names);
// armature->getAnimation()->playByIndex(indexes); // armature->getAnimation()->playWithIndexes(indexes);
armature->setScale(0.2f); armature->setScale(0.2f);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/));
@ -1397,7 +1397,7 @@ void TestEasing::onEnter()
animationID = 0; animationID = 0;
armature = Armature::create("testEasing"); armature = Armature::create("testEasing");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setScale(0.8f); armature->setScale(0.8f);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y));
@ -1418,7 +1418,7 @@ void TestEasing::onTouchesEnded(const std::vector<Touch*>& touches, Event* event
{ {
animationID++; animationID++;
animationID = animationID % armature->getAnimation()->getMovementCount(); animationID = animationID % armature->getAnimation()->getMovementCount();
armature->getAnimation()->playByIndex(animationID); armature->getAnimation()->playWithIndex(animationID);
updateSubTitle(); updateSubTitle();
} }
@ -1439,7 +1439,7 @@ void TestChangeAnimationInternal::onEnter()
Armature *armature = NULL; Armature *armature = NULL;
armature = Armature::create("Cowboy"); armature = Armature::create("Cowboy");
armature->getAnimation()->playByIndex(0); armature->getAnimation()->playWithIndex(0);
armature->setScale(0.2f); armature->setScale(0.2f);
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y));

View File

@ -324,7 +324,7 @@ public:
Hero(); Hero();
virtual void changeMount(cocostudio::Armature *armature); virtual void changeMount(cocostudio::Armature *armature);
virtual void playByIndex(int index); virtual void playWithIndex(int index);
CC_SYNTHESIZE(cocostudio::Armature*, m_pMount, Mount); CC_SYNTHESIZE(cocostudio::Armature*, m_pMount, Mount);
CC_SYNTHESIZE(cocos2d::Layer*, m_pLayer, Layer); CC_SYNTHESIZE(cocos2d::Layer*, m_pLayer, Layer);