Hi all,
I encountered a new problem while filling an array with objects.
This is the thread stack when the error occurs:
void AnimatedCreature::setup(const char * textureName, int lifepoints, int range)
{
std::stringstream str;
str.str("");
str << textureName << "t_";
this->addAnimation(str.str(), 9, 0.1, 999);
}
void AnimatedObject::addAnimation(string str, int numFrames, float tPerFrame, int numOfRounds)
{
AnimationClass * anim = new AnimationClass();
anim->numOfFrames = numFrames;
anim->numOfRounds = numOfRounds;
anim->tPerFrame = tPerFrame;
anim->filename = str;
this->animations->addObject(anim);
}
CCArray.cpp:
void CCArray::addObject(CCObject* object)
{
ccArrayAppendObjectWithResize(data, object);
}
ccCArray.cpp:
/** Appends an object. Capacity of arr is increased if needed. */
void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object)
{
ccArrayEnsureExtraCapacity(arr, 1);
ccArrayAppendObject(arr, object);
}
ccCArray.cpp:
void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra)
{
while (arr->max < arr->num + extra) // here the app crashes with EXC_BAD_ACCESS
{
ccArrayDoubleCapacity(arr);
}
}
When I print out what arr~~>max and arr~~>num are, the app crashes there, so it might be, that these values are uninitialized.
What am I doing wrong?
Thanks in advance.