写了一个函数,报错提示是 EXC_BAD_INSTRUCTION(code = EXC_ARM_UNDEFINED, subcode=0xeed8e78c)
void Entity::onHit(Runner *runner, bool isInVincible, bool isHurtProtection, CCArray *boneArray, CCArray *rectArr){
if (isInVincible) { // 如何处于无敌
}
else
{
CCRect hitArea = this->getSizeBox();
// STATE sType = runner->getCurState()->getType();
CCLOG(“Land hitArea minX:%f, minY:%f, maxX:%f, maxY:%f”, hitArea.getMinX(), hitArea.getMinY(), hitArea.getMaxX(), hitArea.getMaxY());
// int count = boneArray->count();
bool ignore = false;
if (!ignore) {
bool isBackFootHit = false;
bool isFrontFootHit = false;
float xMin, yMin, xMax, yMax;
CCObject *boneItem;
CCARRAY_FOREACH(boneArray, boneItem) {
int boneIndex = boneArray->indexOfObject(boneItem);
CCBone *bone = (CCBone*)boneItem;
CCNode *node = (CCNode*)rectArr->objectAtIndex(boneIndex);
xMin = node->getPositionX();
yMin = node->getPositionY();
xMax = node->getContentSize().width - xMin;
yMax = node->getContentSize().height - yMax;
CCString *boneName = CCString::create(bone->getName());
CCLOG("yMin:%f", yMin);
if ( boneName->compare("fat_l_foot") || boneName->compare("fat_r_foot") ) {
if (yMin < hitArea.getMaxY()) {
isBackFootHit = true;
}
} else if (boneName->compare("thin_l_foot") || boneName->compare("thin_r_foot")) {
if (yMin < hitArea.getMaxY()) {
isFrontFootHit = true;
}
}
}
}
}
}