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);
}
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;
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();
_movementListLoop = loop;
@ -270,7 +274,7 @@ void ArmatureAnimation::play(const std::vector<std::string>& movementNames, int
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();
_movementListLoop = loop;

View File

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

View File

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

View File

@ -324,7 +324,7 @@ public:
Hero();
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(cocos2d::Layer*, m_pLayer, Layer);