该功能未正确校准,但它“工作”(至少在 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 显示的错误: