我遇到运行动作的CCSequence问题,我不明白为什么 我很乐意知道如何调试或解决问题。 这是我的代码:
void Gem::setGemPositionAnimation(Gem* other)
{
//get the current gem pos that is dragged down
CCPoint currentToPoint = this->mySprite->getPosition();
//get the original upper gem pos , that will be replaced with the gem which is down
CCPoint upperOrigGemPoint = getGemPos();
//CCLOG("Gem %s %s upperOrigGemPoint! x:%f ,y:%f",getImageName().c_str(),getGemId().c_str(),upperOrigGemPoint.x,upperOrigGemPoint.y);
//the down gem pos , that the upper gem suppose to go when dragged down
CCPoint otherOrigGemPoint = other->getGemPos();
//CCLOG("Gem %s %s moveToPoint! x:%f ,y:%f",other->getImageName().c_str(),other->getGemId().c_str(),moveToPoint.x,moveToPoint.y);
//down gem move up action
CCMoveTo *moveUp = CCMoveTo::create(0.3f,upperOrigGemPoint);
CCMoveTo *moveDown = CCMoveTo::create(0.3f,otherOrigGemPoint);
//CCActionInterval *moveUp = CCMoveTo::create(0.3f,upperOrigGemPoint);
//CCActionInterval *moveDown = CCMoveTo::create(0.3f,otherOrigGemPoint);
CCSequence* SequenceActionUpAndDown = CCSequence::create(moveUp,moveDown, NULL);
//CCAction* SequenceActionUpAndDown = CCSpawn::create( moveUp,moveDown, NULL);
other->mySprite->runAction(SequenceActionUpAndDown);
// upper gem move down action
CCSequence* SequenceActionDownAndUp = CCSequence::create( moveDown,moveUp, NULL);
//CCAction *SequenceActionDownAndUp = CCSpawn::create(moveDown,moveUp, NULL);
mySprite->runAction(SequenceActionDownAndUp);
}
现在在SequenceActionUpAndDown CCAction中,moveDown没有做向下移动的动画只是跳转到它的“向下”(CCMoveTo * moveDown)位置 up(CCMoveTo * moveUp)动画工作正常 而另一个gem SequenceActionDownAndUp动画工作正常 可能是什么问题?
每个gem都是不同z顺序的CCSprit
答案 0 :(得分:1)
两个序列都运行相同的操作,您需要为每个序列创建单独的操作。