该功能未正确校准但是“工作”(至少在Android上)
void HelloWorld::continueshipMovement() {
CCNode *node = this->getChildByTag(asterioTag);
CCSprite *sprite = (CCSprite*)node;
if (trafico.size() < 0 or sprite->getActionByTag(actionTag)) {
return;
}
std::pair<float, float> valueOfPt = trafico.back();
trafico.pop_back();
CCPoint newPt = ccp(valueOfPt.first, valueOfPt.second);
float distace = ccpDistance(sprite->getPosition(), newPt);
float duration = distace / ShipSpeed;
CCMoveTo *move = CCMoveTo::create(duration, newPt);
CCSequence *moveseq = CCSequence::createWithTwoActions(move, CCCallFunc::create(this, callfunc_selector(HelloWorld::continueshipMovement)));
moveseq->setTag(actionTag);
sprite->runAction(moveseq);
}
当我触摸屏幕时IOS上的应用程序崩溃,从CCNode转换为CCSprite时似乎失败。
这是Xcode显示的错误: