I have what I believe to be a math bug come up that I do not fully understand why it's happening.
if (mNextBottomIndex < mBlocks.size() - 1) {
if (mBlocks[mNextBottomIndex + 1]->getGlobalPosition().y >= -mBlocks[mNextBottomIndex + 1]->getHeight()) {
mBlocks[mNextBottomIndex + 1]->setAlpha(1.0f);
mNextBottomIndex++;
}
}
it's crashing on the evaluation of the inner if statement
because mBlocks.size() = 0
and mNextBottomIndex = 3
(or mNextBottomIndex
equals any number > 0). So my question is, given the variables in the last sentence, how is it even getting past the outer if statement
? The application is not handling these variables in a background thread, and the variables are the same before and after the outer if statement
I corrected the outer if statement
to be
if (mBlocks.size() != 0 && mNextBottomIndex < mBlocks.size() - 1) {
if (mBlocks[mNextBottomIndex + 1]->getGlobalPosition().y >= -mBlocks[mNextBottomIndex + 1]->getHeight()) {
mBlocks[mNextBottomIndex + 1]->setAlpha(1.0f);
mNextBottomIndex++;
}
}
and it doesn't seem to be crashing now.